Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk5 min

Next.js Server Components Explained: When to Use Them and When Not To

Use Next.js Server Components for server-side data and content without browser needs; add focused Client Components for interaction, state, effects, and browser APIs.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

In Next.js App Router, pages and layouts are Server Components by default. Use them for server-side data access and UI that does not need browser features; use Client Components for state, event handlers, effects, and browser APIs. Keep each use client boundary as close as practical to the interactive feature, and compose server-rendered content with client-side controls when both are needed.

What Server and Client Components mean in Next.js

“Server” and “Client” describe component capabilities and module boundaries; they do not mean that only Server Components produce HTML. On an initial page load, Next.js uses the React Server Component (RSC) payload and Client Components to pre-render HTML. That HTML gives the browser an initial preview. The RSC payload helps reconcile the component trees, and JavaScript hydrates Client Components by attaching their event handlers. On later navigations, Next.js can prefetch and cache the RSC payload, while Client Components render on the client.

As an Amazon Associate I earn from qualifying purchases.

The RSC payload contains rendered Server Component output, placeholders and JavaScript references for Client Components, and props passed from server to client. For the current App Router behavior, see the Next.js Server and Client Components guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When should you use a Server Component?

Start with a Server Component for UI that does not need browser-only capabilities, particularly when it reads data from a database or private API. Server-side code can access data near its source without shipping its credentials or query logic in the client bundle. That does not replace authentication or authorization: protect data access and verify that each request is allowed to see the requested data.

Server Components also suit content-focused or mostly static UI. They do not add their own JavaScript to the client bundle, and Next.js can pre-render content. This is a capability, not a promise that every route will be cached or faster: rendering and caching depend on the route and framework behavior.

  • Read from a database or private API, with proper access checks.
  • Render content that does not require state, effects, event handlers, or browser APIs.
  • Keep data queries and server-only credentials out of client-side modules.

See the Next.js data fetching guide for server-side fetching patterns and their rendering implications.

When do you need a Client Component?

Use a Client Component when a feature needs client-side React capabilities: local state, event handlers, effects, or custom hooks that rely on those capabilities. Browser APIs such as window, localStorage, or geolocation also belong on the client because they are not available in the server environment.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • A button changes visible state after a click.
  • A form responds to user input in the browser.
  • An effect synchronizes with a browser API or client-side subscription.
  • A feature reads browser storage or requests geolocation.

The use client directive marks a module as an entry point to the client module graph. Put it at the top of the file, before imports. You generally do not need to repeat it in every file imported beneath that entry point. The imports and descendants of that entry point become part of the client-side module graph, so placing the directive on a large layout can increase the JavaScript surface sent to the browser. See the Next.js use client reference.

How to choose between them

Need Start with Why and what to watch
Database or private API access Server Component Access data near its source and keep credentials and query logic out of the client bundle. Authenticate and authorize requests.
Mostly static or content-focused UI Server Component It does not add its own JavaScript to the client bundle; do not assume every route is cached or faster.
Clicks, input, local state, or effects Client Component These require client-side React capabilities. Keep the boundary around the interaction where practical.
Browser storage, geolocation, or another browser API Client Component The API is available in the browser, not the server environment.
Server-fetched content displayed inside an interactive modal or provider Compose both Pass rendered UI through a slot such as children; place providers deeply enough to leave more of the tree outside the client boundary.
Frequently polled or client-only data Consider client-side fetching The Next.js Backend for Frontend guide identifies these as cases where client-side fetching may be necessary.
Static export deployment Check requirements first A static export has no runtime server, so features that require the Next.js runtime are unsupported.

When either approach seems workable, compare whether the feature needs browser capabilities, where private data access belongs, how much JavaScript reaches the browser, whether slow work needs streaming, how often data changes, and whether the deployment provides a Next.js runtime.

Can a Server Component contain a Client Component?

Yes. A Server Component can render a Client Component as a child and pass it serializable props. This lets the server handle data access and content while a focused client-side component handles interaction.

A Server Component can also pass server-rendered UI into a Client Component through a slot such as children. For example, a client-side modal or provider can wrap content rendered on the server. The server-rendered content does not become client-rendered merely because it is passed as a child; keep the interactive boundary focused on the component that needs it. Props crossing from a Server Component to a Client Component must be serializable by React.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What to watch for with server data and rendering

Slow requests and streaming

An awaited server-side request can delay the part of a route that depends on it. Server fetching is not automatically parallel: independent requests may be structured to run in parallel, while dependent requests necessarily run in sequence. Split work into smaller chunks and use loading UI or Suspense where appropriate so the framework can progressively send content rather than making the entire route wait for every piece of data.

Caching and dynamic rendering

Do not carry caching assumptions from one Next.js version to another. The current fetching guide says fetch requests are not cached by default and can block rendering until completion; check the guide for the exact version you use. The production checklist also notes that dynamic APIs such as cookies and searchParams can opt a route into dynamic rendering. Neither default makes a blanket claim about every route’s cache behavior or speed.

Client-side fetching and static export

Client-side fetching can be a better fit when data is client-only or needs frequent polling. Conversely, a static export cannot provide a runtime server for features that depend on the Next.js runtime. Confirm deployment constraints before relying on server-only capabilities; the relevant Next.js guidance is in its Backend for Frontend guide and static exports guide.

A practical rule for placing use client

  1. Build the route, layout, and content-focused UI as Server Components by default.
  2. Identify the smallest feature that needs state, event handlers, effects, or browser APIs.
  3. Put use client at the top of that feature’s module, before its imports.
  4. Pass the Client Component only the serializable props it needs; pass server-rendered UI as children when composition calls for it.
  5. Review imports beneath the client entry point and avoid moving the boundary higher in the tree without a reason.
  6. Check the rendering, caching, and runtime requirements against the documentation for your Next.js version and deployment target.

This approach follows the Next.js production checklist, which recommends checking Client Component boundary placement to avoid unnecessarily increasing client bundle size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.