Next.js
/Intermediate
Server Side Rendering (SSR)
Definition
A rendering strategy where the HTML is generated on the server for EVERY single request, using the freshest data possible, before being sent to the browser.
Explain Like I'm New
User asks for a page. The server halts, fetches data from the database, builds the HTML, and sends the finished page to the user. It happens completely fresh every single time anyone hits the URL.
Real World Example
A Twitter timeline or a live stock market ticker. The data changes every second, so the server must generate the page on-demand when requested to ensure the user isn't seeing old data.
Common Use Cases
- •Highly dynamic content
- •Personalized user feeds
- •Real-time data
Interactive Example
/* Server Side Rendering in the App Router (Also called 'Dynamic Rendering') */ export default async function LiveStockTicker() { // By adding 'cache: no-store', we FORCE Next.js to run this fetch // and rebuild the HTML on EVERY single user request (SSR) const res = await fetch('https://api.stocks.com/tsla', { cache: 'no-store' }); const data = await res.json(); return ( <div> <h1>TSLA Live Price</h1> <p>${data.price}</p> </div> ); }
Interview Questions
basic
- Is Server-Side Rendering better or worse for SEO than Client-Side Rendering?
intermediate
- What is the main performance drawback of Server-Side Rendering (Dynamic Rendering)?