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

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

Broad 'use client' boundaries can make a Next.js route send and run more JavaScript than it needs. The fix is not to avoid Client Components: keep static UI and server-side work on the server, and put the client boundary around the smallest component that needs state, event handlers, effects, or browser APIs. 'use client' does not turn off server rendering; it marks a boundary in the module graph that affects which code must reach the browser.

What does 'use client' actually do?

'use client' marks a file as an entry point into the Client Component module graph. Its imports and child components become part of that client-side graph, so a directive placed high in a page or layout can bring far more code into the browser bundle than the one interactive control that motivated it.

That is why the directive is not a label to add to every component file, nor a switch that makes a single file’s behavior self-contained. It defines a boundary: the code on the client side of that boundary must be available to the browser. The Next.js documentation describes it as the client-server boundary, and recommends using Client Components for the parts of the interface that need client capabilities.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

In the App Router, Server Components are the default. Think of a page as server-rendered structure with small client islands where interaction begins, rather than a client application with a few server exceptions.

Popular on Amazon
Silkland 40Gbps USB C 90 Degree Right Angle Adapter 2 Pack, 240W USB4 | Male to Female Extender, 8K@60Hz, Thunderbolt 4/3, Steam Deck, ROG Ally, MacBook, Switch 2, iPhone 18/17/16/15, Quest 3 VR
  • 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
  • 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
  • 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
  • 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
  • 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.

Why can a broad client boundary hurt performance?

A large boundary can add JavaScript transfer, parsing, execution, and hydration work. It can also pull in dependencies used by the boundary even when those dependencies only support static content or transformations that could happen on the server.

The visual arrival of a page and its readiness for interaction are not the same milestone. Next.js pre-renders an initial HTML preview for Client Components, so content may appear before their JavaScript has finished loading and hydrating. A page can therefore look complete while a button or other control is not yet interactive. On subsequent navigations, Client Components render on the client, so the client graph matters beyond the initial visit as well.

Next.js says smaller bundles load faster, reduce JavaScript execution time, can improve Core Web Vitals, and can reduce server cold-start costs. Those are reasons to examine unnecessary client code, not a promise that changing one directive will produce a particular score or time saving. The effect depends on the route, its dependencies, network, device, rendering and caching setup, and what users do.

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

What should remain a Server Component?

Keep a component on the server when it can do its job without browser APIs or client-side interaction. Server Components can reduce the JavaScript sent to the browser, and they let server-side work stay close to the data and resources it needs.

Also popular on Amazon
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  • Static and SEO-critical content: headings, articles, product descriptions, navigation structure, and other markup that does not need local interaction.
  • Data access: fetching from an API or working close to a database, where appropriate for the app’s architecture.
  • Secrets and server-only resources: tokens and credentials should stay in server-side code rather than being passed into browser code.
  • Heavy noninteractive transformations: markdown parsing, syntax highlighting, or chart-data preparation when the result is displayed but does not need those libraries in the browser.
  • Page and layout structure: the surrounding shell can stay on the server even if a small search field, menu control, or filter is interactive.

For heavy packages in particular, Next.js package-bundling guidance recommends moving work that does not need client interaction out of Client Components. The goal is not to move every computation to the server regardless of cost; it is to avoid shipping browser code for work that can be completed before the result is sent.

When does a component need a client boundary?

Use a Client Component when its own behavior genuinely depends on browser-side capabilities. Common signals include state, event handlers, effects, browser APIs, or a dependency that requires a browser.

  • State or lifecycle: useState, useReducer, useEffect, or a custom hook that depends on client-side state or effects.
  • Events: handlers such as onClick, onChange, and onSubmit.
  • Browser APIs: access to window, localStorage, geolocation, or similar browser-only features.
  • Browser-dependent third-party code: a component or library that genuinely needs the browser to work.

Put the boundary as close as possible to the interactive leaf. A search box may need client-side state and input handling; the logo, page heading, surrounding navigation, and server-fetched results do not automatically need to become Client Components because they sit nearby.

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

How do you narrow an oversized boundary?

Start by locating the directive that sits above more UI than necessary. Move the interactive behavior into a focused component, then keep its parent page or layout as a Server Component wherever its work does not require the browser.

Also popular on Amazon
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  1. Find the reason for the directive. Identify which behavior requires client capabilities. If the page or layout is marked only because a descendant has a button or input, the boundary is probably too high.
  2. Move the behavior into a small component. Create a component such as SearchBox, LikeButton, DialogTrigger, or FilterControls for the specific interactive feature. Put 'use client' at the top of that component’s entry file.
  3. Keep surrounding work on the server. Leave static markup, data fetching, and noninteractive transformations in the server-rendered page or layout instead of importing all of them through the client entry point.
  4. Pass only the needed data across the boundary. Supply serializable data as props to the Client Component. Server-only values such as secrets do not belong in browser-facing props.
  5. Preserve server-rendered composition where it fits. A Server Component can provide content to a Client Component through supported composition patterns, such as passing server-rendered content as children, rather than moving every descendant into the client graph.
  6. Review providers. If a context provider is needed, render it as deep in the tree as practical instead of wrapping the entire document unnecessarily.
  7. Recheck the resulting graph. Build in a production-like configuration, inspect the route’s client bundle, and verify that the intended static work and heavy dependencies are no longer included unnecessarily.

Illustrative before-and-after shape

A broad arrangement often looks like this:

'use client'

export default function Page() {
  // Static page content and an interactive search control
}

If only the search needs client-side state, move that behavior behind its own boundary:

// Server Component page
import SearchBox from './SearchBox'

export default async function Page() {
  const results = await getResults()

  return (
    <main>
      <h1>Search</h1>
      <SearchBox />
      <Results items={results} />
    </main>
  )
}

// SearchBox entry file
'use client'

export default function SearchBox() {
  // State and event handling for the search field
}

This illustrates the boundary’s placement, not a complete runnable search implementation. In a real app, choose the data and interaction flow to fit the route, and pass only values that can cross the server-client boundary. The page can remain a Server Component even though it renders a Client Component.

Does every file imported by a Client Component need the directive?

No. The directive belongs on the client entry point; repeating it in every file is unnecessary. However, code imported into the client graph from that entry point can still become part of the client bundle, so omitting the directive in a helper file does not make a large browser dependency server-only.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

That distinction matters during refactoring: the number of files containing 'use client' is not the same thing as the amount of code sent to the browser. Follow imports from the boundary and examine what those imports bring with them.

Also popular on Amazon
BENFEI USB C Hub 5-in-1 with 4K HDMI(Certified), 100W Power Delivery, 3 USB-A, Silicone Cable, Aluminum Case Compatible with MacBook Pro/Air, iPad Pro, iMac, iPhone 15 Pro/Pro Max, XPS, Thinkpad
  • Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
  • Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
  • 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
  • 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
  • Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.

How can you find what is making a Next.js bundle large?

Use bundle analysis rather than guessing from the number of directives. Next.js documents a Turbopack bundle analyzer and the @next/bundle-analyzer Webpack plugin; its navigation guidance also recommends bundle analysis to identify large modules and dependencies.

  1. Build and inspect a production-like configuration. Development behavior is not a substitute for understanding the shipped route bundle.
  2. Inspect the route’s client-side output. Look for unexpectedly large modules or dependencies, not just large component files.
  3. Trace imports from broad client entry points. Ask whether each dependency is needed in the browser, or only to create static output.
  4. Move noninteractive work server-side where appropriate. This can keep parsing, highlighting, chart preparation, and similar transformations out of the client graph when their results do not require browser interaction.
  5. Measure the relevant outcomes again. Compare JavaScript transfer and execution, hydration, and Core Web Vitals in a consistent production-like setup.

There is no universal number of milliseconds or percentage that describes the cost of 'use client'. A result from one route, device, dependency graph, or network would not establish a general penalty for another app. Treat the analyzer as a way to find candidates, then judge the change using the route and workload that matter to your users.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What are the trade-offs of Server and Client Components?

The choice is about capabilities and where code runs, not a rule that one component type is always superior. Use the component model that fits each unit of work.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Consideration Server Component Client Component
Typical need Server data, secrets, static output, or noninteractive work State, effects, event handlers, browser APIs, or browser-dependent components
Browser JavaScript Pure Server Component code is not sent as client JavaScript Its module graph must be available to the browser
Interactivity Does not provide client-side event handling or state by itself Can hydrate and respond to browser interactions
Dependency scope Can keep server-only and heavy noninteractive work off the client Imports behind the boundary can enlarge the client graph
Data boundary Can work with server-side resources Receives data across the boundary as serializable props
Navigation behavior Contributes server-generated React Server Component payloads Client Components render on the client during subsequent navigations

A route may use both: server-rendered structure and data alongside small client controls. The performance question is whether each piece of browser code earns its place, not whether a page contains any Client Components at all.

Also popular on Amazon
𝟒𝐏𝐚𝐜𝐤 𝐔𝐩𝐠𝐫𝐚𝐝𝐞𝐝 USB to USB C Adapter,Type-C Female to A Male Charger Converter for iPhone 18 Charger,iWatch Ultra SE 9 10,iPhone 17 Pro Max 16 15 14,Samsung S25,AirPods,iPad,Car,Xbox
  • 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
  • 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
  • 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
  • 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
  • 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.

What mistakes should you avoid?

  • Do not treat the directive as a per-file decoration. It marks an entry point and affects the graph behind it.
  • Do not make a whole page client-side for one control. Isolate the behavior that needs the browser.
  • Do not assume Client Components disable server rendering. Next.js pre-renders HTML for the initial view, then hydrates client portions.
  • Do not assume server rendering guarantees a faster page. Dependencies, caching, rendering mode, devices, and workload all affect the outcome.
  • Do not keep heavy libraries in the client graph just because the output is interactive. Determine whether the library itself must run in the browser, or whether the server can provide the prepared result.
  • Do not judge success only by whether the page appears quickly. Visible HTML can arrive before client code is ready to make controls interactive.

Frequently Asked Questions

Can I read localStorage in a Next.js Server Component?

No. localStorage is a browser API, so code that reads it must run in a Client Component, often after the component mounts. Keep the rest of the page server-rendered if it does not need that value.

Can a Server Component pass a callback function to a Client Component?

Ordinary function props are not serializable values for the server-to-client boundary. Put the event behavior in client-side code, or use an appropriate Next.js server-action pattern when the interaction is meant to invoke server work.

Why does a Client Component sometimes render differently on the server and in the browser?

The initial HTML is pre-rendered, so rendering code that depends on browser-only values can produce a mismatch when the browser hydrates it. Keep browser-dependent reads out of the initial render and handle them in client-side effects or an interaction flow.

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

Can I use a third-party React library in a Server Component?

It depends on what the library does: a library that relies on state, effects, event handlers, or browser APIs needs to run behind a client boundary. For a library used only to transform data into static output, check whether that work can remain on the server.

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. Prices as of November 8, 2026 12:27 am GMT.