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
330
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
next.jsを使ったuniversal React 入門
Hori Godai
December 14, 2018
More Decks by Hori Godai
See All by Hori Godai
TypeScript Compiler APIを使って 型のユニットテストをブラウザーで動かす
steelydylan
3
280
エディター付きのReact開発環境を ブラウザーだけで実装した話
steelydylan
9
2k
HonoでReact・TypeScriptの実行環境をブラウザー上に作る
steelydylan
1
2.6k
複数ピンをまとめて表示するYahoo!地図用のJavaScriptライブラリをつくりま作りました
steelydylan
1
1.3k
Nuxtでのサーバー、クライアント間データ共有について
steelydylan
0
990
a-blog cmsの静的書き出し機能を使って、 自分のブログを100%静的にした話
steelydylan
0
440
MySQLの GEOMETRY 型とJavaScriptの Geolocation API の活用事例
steelydylan
1
530
アップルップルの新しいオープンソースの紹介
steelydylan
0
550
a-blog cms をよくするために 取り組んだ3つのこと
steelydylan
0
640
Other Decks in Programming
See All in Programming
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
160
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
500
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
730
エージェンティックRAGにAWSで入門しよう!
har1101
8
1.2k
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
380
生成AI時代にこそ効くGo | Why Go Works in the Age of Generative AI
mom0tomo
8
3.1k
軽量Java基盤の設計 DIコンテナに頼らない、長期保守と1秒起動の実現 JJUG CCC 2026 Spring
macha64
0
460
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.7k
TSKaigi Night Talks 2026_TypeScriptでサプライチェーンの整合性を型に閉じ込める
geekplus_tech
0
310
3Dシーンの圧縮
fadis
1
670
脅威をエンジニアリングの糧にして――現場編 / Turning Threats into Engineering Fuel — Field Edition
nrslib
0
250
dRuby over BLE
makicamel
2
320
Featured
See All Featured
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
160
Testing 201, or: Great Expectations
jmmastey
46
8.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
320
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
240
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
570
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
54k
Navigating Weather and Climate Data
rabernat
0
210
Abbi's Birthday
coloredviolet
2
7.9k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
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