Iury Lenon Logo
Back to Blog

Understanding Server-Side Rendering in Next.js

Iury LenonIury Lenon
Understanding Server-Side Rendering in Next.js

Server-Side Rendering (SSR) is one of the most powerful features of Next.js. It allows your pages to be rendered on the server before they’re sent to the browser — which means users see the content faster and search engines can easily index it.

In traditional React apps, rendering happens only in the browser. With SSR, Next.js handles the rendering on the server first, then delivers a fully rendered HTML page to the client. This improves both performance and SEO visibility.

To enable SSR in a Next.js page, you can export an async function called getServerSideProps from your page component.

For example:

export async function getServerSideProps() {
const res = await fetch('https://api.example.com/data');
const data = await res.json();

return {
props: { data },
};
}

This simple function ensures your data is fetched and rendered before the page reaches the user.

Next.js gives developers full control — you can use SSR for dynamic content, SSG for static pages, or even combine both strategies within the same project.