Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Next.js meets Netlify
Search
mottox2
May 22, 2019
Technology
3
1.9k
Next.js meets Netlify
Ginza.js #1
demo:
https://next-on-netlify.netlify.com/
mottox2
May 22, 2019
Tweet
Share
More Decks by mottox2
See All by mottox2
もう一歩進めたい OG画像の動的生成
mottox2
7
2.2k
なぜコピペで使うコンポーネント集を利用するのか?
mottox2
8
7.4k
UIコンポーネントライブラリをうまく使うためにできること / components-with-designer
mottox2
7
4k
Figma Plugin公開までの壁を乗り越える
mottox2
3
3.8k
Puppeteerでつくる画像と動画 / images and videos made with puppeteer
mottox2
0
750
手触りのよいウェブを考える / better-mobile-web
mottox2
3
1.9k
組織と権限とSlack App / slack-app-with-roles
mottox2
1
690
SSRを避けるためにやっていること / ssr-alternative
mottox2
9
3.3k
JSXでつくる宣言的UIなプレゼンテーション / jsx-presentation
mottox2
7
33k
Other Decks in Technology
See All in Technology
全員が「作り手」になる。職能の壁を溶かすプロトタイプ開発。
hokuo
1
670
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
73k
茨城の思い出を振り返る ~CDKのセキュリティを添えて~ / 20260201 Mitsutoshi Matsuo
shift_evolve
PRO
1
110
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
Azure SRE Agent x PagerDutyによる近未来インシデント対応への期待 / The Future of Incident Response: Azure SRE Agent x PagerDuty
aeonpeople
0
270
入社1ヶ月でデータパイプライン講座を作った話
waiwai2111
1
210
IaaS/SaaS管理における SREの実践 - SRE Kaigi 2026
bbqallstars
4
1.3k
しろおびセキュリティへ ようこそ
log0417
0
250
SREじゃなかった僕らがenablingを通じて「SRE実践者」になるまでのリアル / SRE Kaigi 2026
aeonpeople
6
1.6k
CDK対応したAWS DevOps Agentを試そう_20260201
masakiokuda
1
120
【5分でわかる】セーフィー エンジニア向け会社紹介
safie_recruit
0
41k
Digitization部 紹介資料
sansan33
PRO
1
6.7k
Featured
See All Featured
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
First, design no harm
axbom
PRO
2
1.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
150
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
170
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
170
Visualization
eitanlees
150
17k
The Cult of Friendly URLs
andyhume
79
6.8k
エンジニアに許された特別な時間の終わり
watany
106
230k
How to build a perfect <img>
jonoalderson
1
4.9k
The Curse of the Amulet
leimatthew05
1
8k
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
Transcript
Next.js meets Netlify 2019.05.22 Ginza.js#1 / @mottox2
フロントエンドエンジニア(Web/iOS) Gatsby, Gridsome maintainer お仕事 OSS mottox2 @ ؿٔ٦ٓٝأ8FCؒٝآص، ⾃⼰紹介
#engineers_lt
#ginzajs Next.js • Next.jsはSSRが組み込まれているReactベースのフレームワーク • pages/以下にエントリーポイントを置くとディレクトリ構造とURL構造が ⼀致する • pages/index.js =>
example.com/ • pages/detail.js => example.com/detail • getInitialPropsというメソッドでサーバーサイドでのデータ取得を⾏う • Next.js v8でserverlessモードが追加された
#ginzajs Netlify • 静的サイトのホスティングに強いホスティングサービス • リポジトリを⽤意してpublish directoryとdeploy commandを設定する だけでデプロイが可能 •
GitHubと相性がよく、masterブランチをproductionにデプロイ。 • デプロイ⽬的のCI設定が不要 • Functions(裏側はAWS Lambda)を使うと動的なレスポンスを返すこと ができる
#engineers_lt Netlify FunctionsでNext.jsのSSRを⾏い サイトを構築する テーマ
#ginzajs Serverless Next.js • next.config.jsにtarget: serverlessを指定してビルド • 各ページごとにファイルが⽣成される。 • /pages/index.js
=> .next/serverless/pages./index.js • /pages/index.js => .next/serverless/pages./detail.js next.config.js
#ginzajs • Cloud Functionsで動かす例 • ⽣成されたファイルを実⾏するだけでSSRが実現できる Serverless Next.js
#ginzajs Netlify Functions • 設定したディレクトリ(functions directory)にあるJSファイルが⼀つの 関数と⾒なされ、固有のURLが付与される。 • 例: functions
directoryにfunctions/を指定した場合 • functions/index.js => example.com/.netlify/functions/index • functions/detail.js => example.com/.netlify/functions/detail netlify.toml
#ginzajs Netlify Functions • Functionの例
#ginzajs Netlify Functions • netlify-lambdaをビルドに利⽤する。 • webpackとbabelの薄いラッパー。指定したディレクトリのJSファイルを ビルドしてくれる。 • src/functionsにソースコードを書いている時
• `netlify-lambda build src/functions` • functions directory(ex. functions/)にビルドされる。
#ginzajs Netlifyのリライト • ただ、FunctionsのURL(ex. example.com/.netlify/functions/index)は⼈ 間に優しくない。 • Netlifyではリライトも⽤意されており、publish directory以下に `_redirects`ファイルにリライトの情報を記述する
public/_redirects
#ginzajs Netlify FunctionsとNext.jsのつなぎこみ • next build && cp -a public/_next/serverless/
pages src/functions/ && netlify-lambda build src/functions • とても煩雑。Cloud Functionsでやっても同じ感 じになります。
#ginzajs Netlify FunctionsとNext.jsのつなぎこみ • Next.jsで⽣成される関数にはreqとresが必要。Functionsの引数と⼀致し ない。 • AWS Labmdaの引数をreqとresを変換するマッパーを⽤意する
#ginzajs Netlify FunctionsとNext.jsのつなぎこみ • Netlifyではリライト先にクエリパラメータを指定できないので、正規表現 でゴリ押し src/functions/post.js
#ginzajs デモ • Demo: https://next-on-netlify.netlify.com/ • Source: https://github.com/mottox2-sandbox/next-on-netlify
#ginzajs まとめ • NetlifyでもSSRできる • ⾃分はFirebaseで同じことをやっています • Firebase + Nuxtの話と被りを感じた
• 既出だったのでNetlifyでやってみました • Netlify、この本がおすすめ(宣伝) • https://booth.pm/ja/items/1316769 • Next.jsを利⽤するならnow.shが⼀番楽です
#ginzajs Thank you! 2019.05.22 Ginza.js#1 / @mottox2