Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
next.jsを使ったuniversal React 入門
Search
Hori Godai
December 14, 2018
Programming
350
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
next.jsを使ったuniversal React 入門
Hori Godai
December 14, 2018
Transcript
23 slides
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
More Decks by Hori Godai
See All by Hori Godai
TypeScript Compiler APIを使って 型のユニットテストをブラウザーで動かす
steelydylan
3
310
エディター付きのReact開発環境を ブラウザーだけで実装した話
steelydylan
9
2.1k
HonoでReact・TypeScriptの実行環境をブラウザー上に作る
steelydylan
1
2.8k
複数ピンをまとめて表示するYahoo!地図用のJavaScriptライブラリをつくりま作りました
steelydylan
1
1.4k
Nuxtでのサーバー、クライアント間データ共有について
steelydylan
0
1k
a-blog cmsの静的書き出し機能を使って、 自分のブログを100%静的にした話
steelydylan
0
460
MySQLの GEOMETRY 型とJavaScriptの Geolocation API の活用事例
steelydylan
1
540
アップルップルの新しいオープンソースの紹介
steelydylan
0
590
a-blog cms をよくするために 取り組んだ3つのこと
steelydylan
0
670
Other Decks in Programming
See All in Programming
AppFunctionsの内部実装を紐解く
hiroaki404
0
110
AWS CDKを理解するために公式の定義を深掘って解説してみる / Understanding AWS CDK by Digging into Its Official Definition
akihisaikeda
3
330
クラウドゲーミングのパフォーマンス最適化に挑む / Cloud Gaming Performance Tuning
vivion
0
360
protojson における文字化けの扱い
kazuki1023
0
460
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
1
400
baseline으로 마이그레이션, 리팩토링 안전하게 맡기기
fornewid
1
1.1k
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
110
How SRE Grew Out of Server-Side Work and Became the Team's Own / サーバサイドから始まったSREを チームに渡すまで
maaaato
0
180
React Native에 현대적인 빌드 도구 더하기: Rollipop 구현기
leegeunhyeok
0
190
まずはコードより業務と向き合う:テーブル解体のためにPdMを呼んだ話
sakawe_ee
0
270
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
Getting Started with Vibe Coding
miccheng
0
250
Featured
See All Featured
Chasing Engaging Ingredients in Design
codingconduct
0
410
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
61k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Test your architecture with Archunit
thirion
2
2.5k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
850
Ruling the World: When Life Gets Gamed
codingconduct
0
450
It's Worth the Effort
3n
188
29k
Code Reviewing Like a Champion
maltzj
529
40k
Bash Introduction
62gerente
615
220k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.5k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
490
Web Performance Is a Journey [PerfNow 2026]
tammyeverts
2
140