Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Web_アプリ_勉強会_FE_BE_.pdf
Search
kaminchu
March 19, 2019
Programming
1.1k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Web_アプリ_勉強会_FE_BE_.pdf
kaminchu
March 19, 2019
More Decks by kaminchu
See All by kaminchu
jawsug_niigata_20220115
kaminchu
0
380
yarnの話.pdf
kaminchu
1
210
React勉強会.pdf
kaminchu
0
370
ルーターの選び方その2.pdf
kaminchu
0
880
ルーターの選び方
kaminchu
0
1.3k
NDS56.pdf
kaminchu
0
160
nds54
kaminchu
0
280
internet
kaminchu
0
3.1k
Other Decks in Programming
See All in Programming
外から家のPCの電源入れたい!をPHPで解決する
kawashimo0
1
140
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
320
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1.5k
[ハンズオン]AIへの指示だけで「五目並べ」を作ってみよう
satoshi256kbyte
1
380
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
機械に任せるテスト、人が見るテスト ⽣成AIで引き直した、運⽤保守フェーズの線引き
dske104
0
190
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
610
Event is what happens
moro
2
840
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
150
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
390
Featured
See All Featured
Navigating Weather and Climate Data
rabernat
0
560
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Practical Orchestrator
shlominoach
192
12k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Building Flexible Design Systems
yeseniaperezcruz
330
41k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
360
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
Sam Torres - BigQuery for SEOs
techseoconnect
PRO
0
580
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
2
950
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
330
The World Runs on Bad Software
bkeepers
PRO
72
12k
Transcript
React のSSR をAWS Lambda 上の Express でServerlessFramework 使っ て簡単に(?) 実装できた話
Web アプリ 勉強会(FE/BE) in Prototype-cafe Vol.1 (2019/03/19 ) 1
⾃⼰紹介 Twitter: @kam1nchu 職種: フロントエンドエンジニア ⾔語: JavaScript, Java 最近: AWS
ばかり触ってます 2
みなさんSSR してますか? 3
4
ではなくて 5
サーバーサイドレンダリング(SSR) とは 少なくとも私たちWeb デベロッパーのここ数年の⽂脈においては、 「( 元々ブラウザ上でしか動かなかった)JavaScript をサーバー内部で実 ⾏して、HTML を⽣成すること」を指します。 出典:
ユーザー体験を向上させるサーバーサイドレンダリング JavaScript — 歴史と利点 6
サーバーサイドレンダリング(SSR) とは 今まで SPA などでは、bundle されたjs をロードし終わるまで、ブラウザに view が表⽰されなかった。 SSR
使うと 事前にある程度レンダリングしたHTML を返しておくことで、初期表 ⽰にかかる時間を短縮できる。 7
でもSSR って結構⼤変? 8
結構簡単( サーバー) react-dom/server の renderToString などが、component から⽂字列を くので、それをExpress でresponse.send すればサーバ側はおしまい。
import * as Express from "express"; import * as React from 'react'; import { renderToString } from 'react-dom/server'; import Component from "component"; const app = Express(); app.get("/", function (req, res) { res.send(renderToString(<Component/>)); }); // ... 9
結構簡単( クライアント) サーバ側のレンダリングだけだと、React のsetState などのjs 使った処 理ができないので、クライアント側もロードさせる。 ※サーバ側でレンダリングされたDOM が再利⽤される import
* as React from 'react'; import * as ReactDOM from 'react-dom'; import Component from "component"; ReactDOM.hydrate( <Component/>, document.getElementById('root') ); // ... 10
え、Express を使うの 11
Express ダルい... js 動かすので、少なくともnodejs は必要 nodejs って管理が結構⼤変 12
AWS Lambda 13
Express on Lambda aws-serverless-express や serverless-http を使うと割と難なく⾏ける import serverless from
"serverless-http"; import * as Express from "express"; const app = Express(); app.get("/", function (req, res) { res.send("hello"); }); exports.handler =serverless(app); 14
Lambda 使うメリット フルマネージドなので管理いらず ~~( いらないとは⾔っていない)~~ Lambda はとてもスケールできる CloudFront やRoute53 など活⽤できる
15
AWS のデプロイって⼤変では? 16
AWS のデプロイ ServerlessFramework 使えば、とても簡単にデプロイできる plugins: - serverless-webpack provider: name: aws
runtime: nodejs8.10 functions: app: handler: app.handler events: - http: method: ANY path: "{proxy+}" 17
他いろいろ TypeScript 使うととても捗る(serverless のテンプレートあります) react-router 使うと、クライアントとサーバのルーティングが共通 化できて便利 その時はExpress で app.get("*",
() => {}) するといい API-Gateway のステージには注意( パスを上⼿に書かないと詰む) Redis やmemcached でレンダリング結果をキャッシュすることもで きるらしい 18
時間があったらデモ 19
おわり 20