SlideShare a Scribd company logo
Lessons Learned from
using in
Production
@PanJ

Panjamapong Sermsawatsri
June, 3 2017

React Bangkok 2.0.0

Pathumwan Institute of Technology
Panjamapong (PanJ) Sermsawatsri
CTO at TakeMeTour

Google Developer Expert in Web Technology
@PanJ
June, 3 2017

React Bangkok 2.0.0

Pathumwan Institute of Technology
Single-page
Application
Single-page Application
1 HTTP(S) Request
• DNS Lookup
• TLS Handshaking
• First Byte
• Last Byte
• If got redirect response (3xx), repeat step 1
Single-page Application
Lessons Learned from Using Next.js in Production
Single-page Application
Static HTML
Single-page Application
First paint starts here
Server-side Rendering
(SSR)

to the Rescue
Server-side Rendering
Rendered HTML
Server-side Rendering
First paint starts here
Interaction is ready here
Lessons Learned from Using Next.js in Production
Server-side Rendering
inline only used CSS
Server-side Rendering
First paint starts here
Server-side Rendering
Still long time-to-interact
Code Splitting

to the Rescue
Code-splitting
main.js
home.js
product.js
about.js
Code-splitting
prefetch in idle period
time-to-interact
Lessons Learned from Using Next.js in Production
How to implement
all of these?
Code-spliting
Inline Critical CSS
Server-side Rendering
Prefetching
Lessons Learned from Using Next.js in Production
comes with
• Server-side rendering
• Automatic code-splitting
• Prefetch support
• Inline critical CSS
• Built-in routing
Next.js 2 is
production-ready
Lessons Learned from Using Next.js in Production
But!
There are few things you
might need to know
Higher-order Component
• Each page in Next.js is completely separated
• You must use HOC to create a shared
environment
• Styles, Navbar, Redux, i18n, initalProps
Lessons Learned from Using Next.js in Production
styled-jsx
Wow! template string literal!!!
styled-jsx
Only this part can be templated
styled-jsx
Styling
• Styled-jsx is painful if you are migrating
component from previous project
• You can use SCSS / postcss / cssnext to help
reduce this pain
• After P’Khame’ session, I recommend 

styled-component
comes with
• Server-side rendering
• Automatic code-splitting
• Prefetch support
• Inline critical CSS
• Built-in routing
Optimized for SEO

and landing pages
Migrating to
Optimizing Page Speed
• Keep bundle small
• Reduce first request load
time
Optimizing Page Speed
• Keep bundle small
• Reduce first request load
time
Keep bundle small
• Home
• Product Category
• Product Detail
• About Us
• Dashboard
• Settings
• Checkout
• Notifications
SEO / Landing pages Non-SEO pages
Keep bundle small
• Home
• Product Category
• Product Detail
• About Us
• Dashboard
• Settings
• Checkout
• Notifications
Legacy (?) React Site
Seamless routing
between 2 apps
Legacy
/product/2 /dashboard
Lessons Learned from Using Next.js in Production
Optimizing Page Speed
• Keep bundle small
• Reduce first request load
time
Reduce first request load
time
App
API DB
Reduce first request load
time
App
API DB
Static Caching

to the rescue
Static Caching
App
API DB
Static Caching
NEXT
API DB
L
Static Caching is
Dangerous
Static Caching is
Dangerous
• Every request with same URL will respond the
same content
• Session / Login data must be retrieve in client-
side via componentDidMount
• Side-effect is not allowed in each request (E.g.
counting page view from server-side)
NEXT
API DB
L
Reduce first request load
time
Lessons Learned from Using Next.js in Production
Lessons Learned from Using Next.js in Production
MISS
HIT
Kapook.com
Lessons Learned from Using Next.js in Production
GitHub
Lessons Learned from Using Next.js in Production
https://latency.apex.sh
made by

TJ Holowaychuk
Global Latency Test Tool
Speed Matters
50%
> 3 second
to load.
of users will drop is page takes
Let’s build not
just cool but
fast website
Wanna learn and build cool stuffs?
We are hiring!
Send your GitHub repo to 

WantToWork@takemetour.com
Panjamapong Sermsawatsri
@PanJ
Q&A

More Related Content

PDF
NextJS, A JavaScript Framework for building next generation SPA
PDF
ReactJS presentation
PPTX
React web development
PDF
Introduction to React Native
PPT
React js
PPTX
Adapter Design Pattern
PDF
NextJS - Online Summit for Frontend Developers September 2020
PPTX
React Class Components vs Functional Components: Which is Better?
NextJS, A JavaScript Framework for building next generation SPA
ReactJS presentation
React web development
Introduction to React Native
React js
Adapter Design Pattern
NextJS - Online Summit for Frontend Developers September 2020
React Class Components vs Functional Components: Which is Better?

What's hot (20)

PDF
React Router: React Meetup XXL
PPTX
React hooks
PPTX
React JS - A quick introduction tutorial
PDF
Introduction to React JS
PPTX
Sessions in php
PPTX
React-JS.pptx
PPTX
Angular 14.pptx
PDF
Next.js Introduction
PDF
Best Practice-React
PPTX
Intro to React
PDF
3. Java Script
PPTX
Intro to React
PPTX
PPTX
HTML, CSS And JAVASCRIPT!
ODP
Introduction to ReactJS
PDF
An introduction to React.js
PPTX
PPTX
reactJS
React Router: React Meetup XXL
React hooks
React JS - A quick introduction tutorial
Introduction to React JS
Sessions in php
React-JS.pptx
Angular 14.pptx
Next.js Introduction
Best Practice-React
Intro to React
3. Java Script
Intro to React
HTML, CSS And JAVASCRIPT!
Introduction to ReactJS
An introduction to React.js
reactJS
Ad

Similar to Lessons Learned from Using Next.js in Production (20)

PDF
Isomorphic React Applications: Performance And Scalability
PDF
Performance and Scalability Art of Isomorphic React Applications
PDF
Using React for the Mobile Web
PPTX
Next.js - ReactPlayIO.pptx
PDF
Next.js and the pursuit of happiness (Dimitris Michalakos, Lead Developer at ...
PDF
10 Web Performance Lessons For the 21st Century
PPTX
Web Performance & Latest in React
PDF
Offline of web applications
PDF
Offline for web - Frontend Dev Conf Minsk 2014
PDF
Bringing the JAMstack to the Enterprise
PDF
VueJS in Action
PPTX
intro to react| React: dynamic UIs, component-based, virtual DOM, JSX, effici...
PDF
What is Server-side Rendering? How to Render Your React App on the Server-sid...
PDF
Best 10 Advantages Of React.js Development For Your Business
PPTX
Client Side Performance for Back End Developers - Cambridge .NET User Group -...
PDF
Thinking Beyond Core Web Vitals - Web performance optimisations for the harsh...
PDF
Stefan Judis "Did we(b development) lose the right direction?"
PDF
A year with progressive web apps! #DevConMU
PPTX
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Isomorphic React Applications: Performance And Scalability
Performance and Scalability Art of Isomorphic React Applications
Using React for the Mobile Web
Next.js - ReactPlayIO.pptx
Next.js and the pursuit of happiness (Dimitris Michalakos, Lead Developer at ...
10 Web Performance Lessons For the 21st Century
Web Performance & Latest in React
Offline of web applications
Offline for web - Frontend Dev Conf Minsk 2014
Bringing the JAMstack to the Enterprise
VueJS in Action
intro to react| React: dynamic UIs, component-based, virtual DOM, JSX, effici...
What is Server-side Rendering? How to Render Your React App on the Server-sid...
Best 10 Advantages Of React.js Development For Your Business
Client Side Performance for Back End Developers - Cambridge .NET User Group -...
Thinking Beyond Core Web Vitals - Web performance optimisations for the harsh...
Stefan Judis "Did we(b development) lose the right direction?"
A year with progressive web apps! #DevConMU
Client Side Performance for Back End Developers - Camb Expert Talks, Nov 2016
Ad

Recently uploaded (20)

PDF
Electronic commerce courselecture one. Pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Transforming Manufacturing operations through Intelligent Integrations
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....
Electronic commerce courselecture one. Pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Review of recent advances in non-invasive hemoglobin estimation
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Advanced methodologies resolving dimensionality complications for autism neur...
GamePlan Trading System Review: Professional Trader's Honest Take
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Transforming Manufacturing operations through Intelligent Integrations
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Diabetes mellitus diagnosis method based random forest with bat algorithm
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
NewMind AI Weekly Chronicles - August'25 Week I
Telecom Fraud Prevention Guide | Hyperlink InfoSystem
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
NewMind AI Monthly Chronicles - July 2025
Chapter 3 Spatial Domain Image Processing.pdf
breach-and-attack-simulation-cybersecurity-india-chennai-defenderrabbit-2025....

Lessons Learned from Using Next.js in Production