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
1.9k
3
Share
Next.js meets Netlify
Ginza.js #1
demo:
https://next-on-netlify.netlify.com/
mottox2
May 22, 2019
More Decks by mottox2
See All by mottox2
つくり方を変えていく | change-how-we-build
mottox2
2
1.2k
もう一歩進めたい OG画像の動的生成
mottox2
7
2.5k
なぜコピペで使うコンポーネント集を利用するのか?
mottox2
8
7.5k
UIコンポーネントライブラリをうまく使うためにできること / components-with-designer
mottox2
7
4k
Figma Plugin公開までの壁を乗り越える
mottox2
3
4k
Puppeteerでつくる画像と動画 / images and videos made with puppeteer
mottox2
0
770
手触りのよいウェブを考える / better-mobile-web
mottox2
3
2k
組織と権限とSlack App / slack-app-with-roles
mottox2
1
710
SSRを避けるためにやっていること / ssr-alternative
mottox2
9
3.3k
Other Decks in Technology
See All in Technology
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
390
Oracle Cloud Infrastructure:2026年4月度サービス・アップデート
oracle4engineer
PRO
0
230
プラットフォームエンジニアリングの実践 - AWS コンテナサービスで構築する社内プラットフォーム / AWS Containers Platform Meetup #1
literalice
1
230
Forget technical debt
ufried
0
140
GitHub Copilot Dev Days
tomokusaba
0
120
AI와 협업하는 조직으로의 여정
arawn
0
560
生成AIが変える SaaS の競争原理と弁護士ドットコムのプロダクト戦略
bengo4com
1
3.1k
MCPサーバーを中核としたAIエージェント開発と業務自動化/nikkei-tech-talk-45
nikkei_engineer_recruiting
0
100
AI時代 に増える データ活用先
takahal
0
350
No Types Needed, Just Callable Method Check
dak2
1
2.6k
需要創出(Chatwork)×供給(BPaaS) フライホイールとMoat 実行能力の最適配置とAI戦略
kubell_hr
0
1.6k
色を視る
yuzneri
0
290
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
350
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
1
530
A Modern Web Designer's Workflow
chriscoyier
698
190k
Done Done
chrislema
186
16k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
330
Joys of Absence: A Defence of Solitary Play
codingconduct
1
350
WCS-LA-2024
lcolladotor
0
560
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
190
Writing Fast Ruby
sferik
630
63k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
120
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
390
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