Getting started with Next.js
Feb 27, 2020
Gokhan Sari
@hgokhansari
WebGazer
A web application!
component
/kəmˈpoʊ.nənt/
a part that combines with other parts to form
something bigger
React!
Starting a React project
Webpack
Babel
Routing
Going to production
Static export
Code splitting
Server-side rendering
React doesn’t have these.
And that’s a good thing!
Starting a project
(from scratch)
1. yarn init best-app-ever
2. yarn add --dev webpack
3. Start to read about babel and presets
4. Understand the history of javascript
5. Set up webpack loaders for images
6. Set up hot code reloading for dev environment
7. ….
Starting a project
(Next.js)
$ yarn create next-app
Starting a project
(Next.js)
● Batteries included
● Sane defaults
● Fully extensible
● Ready for production
Server-Side Rendering
(SSR)
and
Client-Side Rendering
(CSR)
Client-Side Rendering (CSR)
Server-Side Rendering (SSR)
First page is ready to render
HTML, like good old days
And then we have a regular
single-page application
Client-Side Rendering (CSR)
Server-Side Rendering (SSR)
CSR SSR
Server-Side Rendering (SSR)
■ Search engine optimization
■ Social media optimization
■ User experience
Code splitting
Code splitting
bundle.js
The user doesn’t need all of your 19 MB bundle.js in
order to see your ‘about’ page.
Code splitting
It breaks javascript bundle into pieces and loads only when
needed.
users.js
x.js
products.js
y.js
z.js
common.js
users.js
products.js
Code splitting
Next.js does automatic code splitting and it is based on
the pages in your app.
“For example, if one of your modules is used at-least in half of
your pages, then it moves into the main JavaScript bundle. If
not, that module stays inside the page's bundle.”
Static exporting
● Marketing websites
● Documentations
● Blogs
To sum up
● Boilerplate-free
● Featureful by default
● Server-side rendering
● Code splitting
● Static exporting
● UNOPINIONATED
References
● Cambridge dictionary (https://dictionary.cambridge.org)
● React Documentation (https://reactjs.org/docs/)
● Next.js Documentation (https://nextjs.org/docs/)
● Reddit - /r/ProgrammerHumor
(https://www.reddit.com/r/ProgrammerHumor/)
Getting started with Next.js

Getting started with Next.js