Skip to content

Server Component in Nextjs

Posted on:February 23, 2025 at 07:09 AM

Nextjs is a React framework that offers server-side rendering (SSR) that enables developers to build web applications that run on server.

In Nextjs 13+ that comes with App Router, there’s new feature Server Components. Server Components are a new way to create component that render on the server. Server component execute only on the server and never sent to the browser.

By default, all components inside the /app folder are Server Components. This means we cannot use useEffect, useState or other hooks that run only on the client. However, we can create a separate component specifically for client-side feature and add "use client" at top of the component file to indicate that it should run on client / browser side.

There are some benefits we will get by using Server Components: