- File-System Routing ‘pages/index.js’
- Image optimization ‘next/image’
- Fast Refresh
- Static Assets ‘public/’
- Built-in CSS support
- API Routes ‘pages/api/user.js’
- Code Splitting & Bundling
- TypeScript Support
- Client Side Rendering (CSR)
- Server Side Rendering (SSR)
- Static Site Generation (SSG)
- Incremental Static Regeneration (ISR)
- Server renders the page without any dynamic data
- Client immediately shows the page (without dynamic data)
- Page displays a loading state (for loading dynamic data)
- Next.js makes all the API calls (to fetch dynamic data)
- Next.js renders missing dynamic data on the client side
- Page gets display immediately
- Build single page application
- No initial render dynamic data
- Bad for search engine optimization
- Private dashboard pages
- E-commerce sites cart page
- Pages where SEO is not relevant
- Pages with frequently updating data
- Banking sites (request data securely only when needed)
- Server pre-renders the page with dynamic data
- Client shows the pre-rendered page
- Next.js sends an API request to the server
- Server runs the getServerSideProps
- Server returns resulting JSON as a response
- Next.js uses this JSON response to render the page
- Dynamic content is available when page render
- Good for Search Engine Optimization
- Page has no blank loading state since it’s pre-rendered
- Slower time to first byte (due to pre-rendering), we have to wait a little bit before render a page
- Slower rendering on the server
- Results cannot be cached by a CDN without extra configuration
- Incompatible with libraries that need access to the Document
- When pages data must be fetched at request time
- When you have lots of page
- Pages with heavy work-load (easier for server than client)
- Server generates the page on build time
- Server generates pages with or without dynamic data
- Client immediately shows the static generated page
- Server generates pages with defined paths on build time
- Client immediately shows the static generated page
- If a user requests a non-generated page (undefined path)
- Next.js will serve a “fallback” version (loading state)
- Next.js will send an API request to the server
- Server will statically generate this page in the background
- Next.js will serve the generated page to the browser
- Next.js will add this path to the list of pre-generated pages
- On a subsequent request to same path (generated above)
- Next.js will serve the generated page
- Just like other pages pre-generated at the build time
- Incredibly fast
- Build once and served by CDN
- Page gets cached for long time (until the new build)
- Page gets displayed immediately
- Build Offline progressive web apps
- Generate millions of pages incrementally
- Great for Search Engine Optimization (SEO)
- No server needed (CDN only / non-incremental)
- Slow server side site-builds
- Incompatible with libraries that need access to the document
- Blog posts
- Marketing pages
- Help and documentation
- E-commerce product listings
- Pages that are infrequently updated
https://blog.logrocket.com/incremental-static-regeneration-with-next-js/