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
Isomorphic Web Apps with React
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Kristian Andersen
February 25, 2016
Programming
46
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Isomorphic Web Apps with React
Kristian Andersen
February 25, 2016
More Decks by Kristian Andersen
See All by Kristian Andersen
Flexbox all the things
ksmandersen
2
160
Static Websites with Gulp & AWS
ksmandersen
0
130
Practical MVVM
ksmandersen
0
220
Practical Swift
ksmandersen
1
210
Introduction to CocoaLumberjack
ksmandersen
0
120
Other Decks in Programming
See All in Programming
Inside Stream API
skrb
1
720
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
230
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
770
Semantic Version 単位で戦略を柔軟に変えて、パッケージアップデートを自動化する
daitasu
1
240
RTSPクライアントを自作してみた話
simotin13
0
610
CSC307 Lecture 17
javiergs
PRO
0
320
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
決定論的オーケストレーションの設計と実装 / Design and Implementation of Deterministic Orchestration
nrslib
4
1.4k
フロントエンドとバックエンドで「1文字」を揃えよう
youkidearitai
PRO
0
700
技術記事、AIに書かせるか、自分で書くか? 〜それでも私が自分の手で書く理由〜 / #QiitaConference
jnchito
2
1.4k
Oxlintのカスタムルールの現況
syumai
6
1.1k
コンテキストの使い捨てをやめる — ビジネスルール駆動開発と miko —
ioki
0
200
Featured
See All Featured
How to Talk to Developers About Accessibility
jct
2
230
Faster Mobile Websites
deanohume
310
31k
Building the Perfect Custom Keyboard
takai
2
800
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
390
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
210
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
A Soul's Torment
seathinner
6
2.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
Marketing to machines
jonoalderson
1
5.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
330
Transcript
@CPHFRONT ⎯ @KSMANDERSEN
ISOMORPHIC WEB APPS
IN THE BEGINNING
AND THUS JAVASCRIPT WAS BORN
THE CRAZY ENGINEERS @ GOOGLE
LET'S RUN JAVASCRIPT ON SERVERS
ISOMORPHIC WEB APPS
UNIVERSAL WEB APPS
WHAT IT IS > An app that runs both on
the server and the client > Rendering can be done both by the server and the browser > The apps share at least 90% of the same code
None
None
CLIENT-SIDE RENDERING > Rendering done client-side takes load away from
the server > Consecutive page navigation is very fast > Fancy interactions, animations and rainbows
SERVER-SIDE RENDERING > More load on the server for rendering
> Page content visible to bots, search engines and crazy people > The initial page load is faster (no app to boot client- side)
ISOMORPHIC RENDERING > The best of both worlds > Fast
initial page load (server-side rendering) > Consecutive page loads are very fast (client-side rendering) > Page content visible for bots, search engines and crazy people
None
WHY IS REACT GREAT FOR ISOMORPHIC WEB APPS?
COMPONENTS COMPONENTS COMPONENTS
THE VIRTUAL DOM
await Router.dispatch({ path: req.path, query: req.query, context }, (state, component)
=> { data.body = ReactDOM.renderToString(component); });
DE-COUPLED ROUTING
const router = new Router(on => { on('*', async (state,
next) => { const component = await next(); return component && <App context={state.context}>{component}</App>; }); on('/login', async () => <LoginPage />); });
EXPRESS.JS
const server = global.server = express(); server.get('*', async (req, res,
next) => { res.status(200).send(`Hello World`); });
GREAT HOW DO I GET STARTED?
None
HOW IT ACTUALLY WORKS
None
SERVER.JS const server = global.server = express(); server.get('*', async (req,
res, next) => { try { const data = { title: '', description: '', css: [], body: '', entry: assets.main.js }; const context = { insertCss: styles => data.css.push(styles._getCss()), ... }; await Router.dispatch({ path: req.path, query: req.query, context }, (state, component) => { data.body = ReactDOM.renderToString(component); data.css = css.join(''); }); const html = ReactDOM.renderToStaticMarkup(<Html {...data} />); res.status(200).send(`<!doctype html>\n${html}`); } catch (err) { next(err); } }); server.listen(port, () => {});
DEMO TIME
@CPHFRONT ⎯ @KSMANDERSEN