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
Isomorphic Web Apps with React
Search
Kristian Andersen
February 25, 2016
Programming
58
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
Transcript
30 slides
@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
More Decks by Kristian Andersen
See All by Kristian Andersen
Flexbox all the things
ksmandersen
2
170
Static Websites with Gulp & AWS
ksmandersen
0
150
Practical MVVM
ksmandersen
0
240
Practical Swift
ksmandersen
1
220
Introduction to CocoaLumberjack
ksmandersen
0
130
Other Decks in Programming
See All in Programming
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
2.4k
protojson における文字化けの扱い
kazuki1023
0
420
LLM 101
dalinaum
0
490
仕様駆動開発入門 (何を作るかを先に決めて渡す) | 目指せ Kiro マスター 05
inariku
PRO
2
150
느린 네트워크와 저사양 디바이스 사용자를 위한 웹뷰 로딩 시간 개선기
kmkim
1
240
小さなアプリを作って公開するまで
onozaty
0
170
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
350
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
370
Modernizing iOS Apps
seyfoyun
0
150
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
130
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
オーケストレーション記述言語 Katari
yukikurage
0
260
Featured
See All Featured
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
300
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
660
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
560
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
350
How to Think Like a Performance Engineer
csswizardry
28
2.9k
Fantastic passwords and where to find them - at NoRuKo
philnash
53
4k
The Language of Interfaces
destraynor
162
27k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
Producing Creativity
orderedlist
PRO
348
41k
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
2
450
Believing is Seeing
oripsolob
1
280