No history yet

Introduction to Server-Side Rendering

How Pages Get to Your Screen

When you visit a website, your browser asks a server for the page's content. How that content is prepared and sent back is called rendering. Think of it like ordering food. You could get a meal kit to assemble yourself, a pre-made sandwich from the cooler, or a dish cooked fresh in the kitchen just for you. Web pages work in a similar way.

Next.js is a powerful framework because it lets developers choose the best rendering method for each page. One of the most important methods is Server-Side Rendering, or SSR.

Server-side rendering (SSR) is the process of rendering web pages on the server and sending fully-rendered HTML to the client.

With SSR, when you request a page, the server does all the work. It gathers the necessary data, builds the complete HTML file, and sends this ready-to-display page to your browser. Your browser receives a finished product and can show it immediately.

The Rendering Trio

To understand why SSR is so useful, it helps to compare it with the other common methods: Client-Side Rendering (CSR) and Static Site Generation (SSG).

Client-Side Rendering (CSR) is the default for many modern web frameworks like React. The server sends a very basic HTML shell and a bundle of JavaScript. Your browser then executes the JavaScript, which builds the page content from scratch. This can be slow to start, and users might see a blank white screen for a moment. It can also be challenging for search engines to understand the content, as they may only see the initial empty shell.

Static Site Generation (SSG) is the opposite. All pages are fully built ahead of time and stored as static HTML files. When you visit a page, the server just sends the corresponding file. This is incredibly fast, but it's only suitable for content that doesn't change often, like a blog post or documentation. If you need to show personalized information, SSG isn't the right fit.

SSR offers a powerful middle ground. It combines the dynamic nature of CSR with the performance benefits of having a complete page sent from the server.

The Benefits of SSR

Choosing SSR brings two major advantages, especially for sites with dynamic content that need to be fast and discoverable.

The first major benefit is a faster initial page load. Because the server sends a fully formed page, the browser can display it almost instantly. The user sees meaningful content right away instead of a loading spinner. This greatly improves the user experience.

Modern web applications increasingly leverage server-side rendering (SSR) to improve initial load times and search engine optimization.

The second key benefit is better Search Engine Optimization (SEO). Search engine crawlers (like Googlebot) can easily read and index the content of an SSR page because the HTML they receive is complete. With client-side rendering, crawlers might struggle to see the final content because it's built by JavaScript after the initial load. A well-indexed site is more likely to rank higher in search results.

By rendering pages on the server, Next.js ensures your site is both fast for users and clear for search engines.

Quiz Questions 1/5

What is the primary responsibility of the browser in Client-Side Rendering (CSR)?

Quiz Questions 2/5

Which rendering method is most suitable for a blog or documentation site where content rarely changes?

Now you have a solid grasp of what Server-Side Rendering is and why it's a core feature of Next.js.