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
210
next.jsを使ったuniversal React 入門
Hori Godai
December 14, 2018
Tweet
Share
More Decks by Hori Godai
See All by Hori Godai
エディター付きのReact開発環境を ブラウザーだけで実装した話
steelydylan
8
1.5k
HonoでReact・TypeScriptの実行環境をブラウザー上に作る
steelydylan
1
1.5k
複数ピンをまとめて表示するYahoo!地図用のJavaScriptライブラリをつくりま作りました
steelydylan
1
800
Nuxtでのサーバー、クライアント間データ共有について
steelydylan
0
700
a-blog cmsの静的書き出し機能を使って、 自分のブログを100%静的にした話
steelydylan
0
200
MySQLの GEOMETRY 型とJavaScriptの Geolocation API の活用事例
steelydylan
1
360
アップルップルの新しいオープンソースの紹介
steelydylan
0
410
a-blog cms をよくするために 取り組んだ3つのこと
steelydylan
0
450
Other Decks in Programming
See All in Programming
Kotlin Multiplatform at Stable and Beyond (Android Makers 2024)
zsmb
0
290
TCAとKMPを用いた新規動画配信アプリ 「ABEMA Live」の設計
tomu28
1
110
Anthropic Cookbook のおすすめレシピ
schroneko
7
980
1BRC--Nerd Sniping the Java Community
gunnarmorling
0
340
ADRを一年運用してみた/adr_after_a_year
hanhan1978
7
2.4k
PHPの次期バージョンはこの時期どうなっているのか - Internalsの開発体制について - PHPカンファレンス小田原
youkidearitai
PRO
1
190
CA.swift19 恋するAIアプリ開発の裏側
oskmr
0
360
What We Can Learn From OSS
inouehi
0
420
Azure OpenAI Serviceのプロンプトエンジニアリング入門
tomokusaba
3
710
Scalable Customer Journey Orchestration (CJO)
lewuathe
0
340
Fast JSX: Don't clone props object #28768
yossydev
1
130
FigmaとPHPで作る1ミリたりとも表示崩れしない最強の帳票印刷ソリューション
ttskch
43
19k
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
59
7.1k
The Brand Is Dead. Long Live the Brand.
mthomps
49
29k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
60
14k
Adopting Sorbet at Scale
ufuk
68
8.6k
Statistics for Hackers
jakevdp
789
220k
How To Stay Up To Date on Web Technology
chriscoyier
782
250k
Faster Mobile Websites
deanohume
299
30k
Why Our Code Smells
bkeepers
PRO
331
56k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
125
32k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
19
1.7k
No one is an island. Learnings from fostering a developers community.
thoeni
16
2.1k
Atom: Resistance is Futile
akmur
259
25k
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