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を使ったuniversal React 入門
Search
Hori Godai
December 14, 2018
Programming
1
320
next.jsを使ったuniversal React 入門
Hori Godai
December 14, 2018
Tweet
Share
More Decks by Hori Godai
See All by Hori Godai
TypeScript Compiler APIを使って 型のユニットテストをブラウザーで動かす
steelydylan
3
250
エディター付きのReact開発環境を ブラウザーだけで実装した話
steelydylan
9
2k
HonoでReact・TypeScriptの実行環境をブラウザー上に作る
steelydylan
1
2.5k
複数ピンをまとめて表示するYahoo!地図用のJavaScriptライブラリをつくりま作りました
steelydylan
1
1.2k
Nuxtでのサーバー、クライアント間データ共有について
steelydylan
0
960
a-blog cmsの静的書き出し機能を使って、 自分のブログを100%静的にした話
steelydylan
0
420
MySQLの GEOMETRY 型とJavaScriptの Geolocation API の活用事例
steelydylan
1
500
アップルップルの新しいオープンソースの紹介
steelydylan
0
530
a-blog cms をよくするために 取り組んだ3つのこと
steelydylan
0
610
Other Decks in Programming
See All in Programming
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
5.9k
CSC307 Lecture 04
javiergs
PRO
0
650
MUSUBIXとは
nahisaho
0
130
AIによるイベントストーミング図からのコード生成 / AI-powered code generation from Event Storming diagrams
nrslib
2
1.8k
【卒業研究】会話ログ分析によるユーザーごとの関心に応じた話題提案手法
momok47
0
190
AIと一緒にレガシーに向き合ってみた
nyafunta9858
0
160
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
140
登壇資料を作る時に意識していること #登壇資料_findy
konifar
1
620
dchart: charts from deck markup
ajstarks
3
990
[KNOTS 2026登壇資料]AIで拡張‧交差する プロダクト開発のプロセス および携わるメンバーの役割
hisatake
0
240
公共交通オープンデータ × モバイルUX 複雑な運行情報を 『直感』に変換する技術
tinykitten
PRO
0
210
SourceGeneratorのススメ
htkym
0
190
Featured
See All Featured
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
120
The Limits of Empathy - UXLibs8
cassininazir
1
210
Data-driven link building: lessons from a $708K investment (BrightonSEO talk)
szymonslowik
1
910
The Language of Interfaces
destraynor
162
26k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Mind Mapping
helmedeiros
PRO
0
75
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
Build your cross-platform service in a week with App Engine
jlugia
234
18k
HU Berlin: Industrial-Strength Natural Language Processing with spaCy and Prodigy
inesmontani
PRO
0
190
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.3k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
130
Transcript
next.jsを使ったuniversal React入門
自己紹介
自己紹介 @steelydylan React, TypeScript が大好きなフロントエンドエンジニア
目次 Universal JavaScriptとは Reactを使う場合 next.jsがオススメの理由 next.js 説明 next.js高度な使い方 netlifyとは netlifyとの連携
lambda functionとは netlifyの lambda function の利用
Universal JavaScriptとは フロントエンド、サーバーサイドに左右されず一貫して動くJavaScript のこと
Reactの場合 Express.js next.js
Next.jsがおすすめ 理由 TypeScriptを使いやすい フロントエンドとサーバーサイドで処理をわけやすい
next.jsがおすすめ $ npm install --save next react react-dom
next.jsがおすすめ { "scripts": { "dev": "next", "build": "next build", "start":
"next start" } }
next.jsがおすすめ ./pages/index.js を作成し、 export default () => <div>Welcome to next.js!</div>
next.jsがおすすめ これだけ!
next.js高度な設定 TypeScriptを利用 styled‑componentをSSRする
TypeScriptを利用 Babelのpresetを下記のように記述 .babelrc "presets": [ "next/babel", "@zeit/next-typescript/babel" ], next.config.js const
withTypescript = require('@zeit/next-typescript') const withCSS = require('@zeit/next-css') module.exports = withTypescript(withCSS());
styled‑componentをSSR .babelrc "plugins": [ [ "styled-components", { "ssr": true, "displayName":
true, "preprocess": false } ] ]
netlifyとは 静的サイトを簡単に公開することができるサイト gitとの連携が容易で、pushされた時のビルドコマンドを指定することが できる! npm run build など
netlifyとの連携 package.json "scripts": { "build": "next build && npm run
lambda" }
lambda function とは サーバーを必要とせず、必要時にのみ関数を実行できるもの Node.jsなどの言語にも対応している。
netlifyの lambda function の利用 npm install netlify-lambda --save-dev
netlifyの lambda function の利用 package.json "scripts": { "lambda": "netlify-lambda build
functions", "lambda-local": "netlify-lambda serve functions", }
netlifyの lambda function の利用 netlify.tomlの作成 [build] command = "npm run
export" publish = "out" functions = "lambda"
netlifyの lambda function の利用 記述例 exports.handler = async (event, context,
callback) => { return callback(null, { statusCode: 200, headers: { 'Content-type': 'application/json' }, body: JSON.stringify({ test: 'hoge' }) }); };
netlifyの lambda function の利用 run.jsという名前で作成した場合、下のURLでアクセス可能 https://example.com/.netlify/functions/run
実際のgithubレポジトリ https://github.com/steelydylan/next‑starter‑kit