What this thread does
Do first: move the interactive part into a component entry file and place 'use client' before its imports.
Short answer
An App Router page or layout starts as a Server Component. State hooks such as useState, event handlers such as onClick and onChange, effects such as useEffect, and browser APIs such as localStorage or window belong on the client side of the boundary. Keep that boundary close to the interactive component so a whole layout does not acquire its client dependencies.
What to do
1. Add 'use client' at the top of the interactive component's file, above imports. The docs use app/ui/counter.tsx as an example. Files imported through this entry and components it directly renders join the client module graph; child modules within that graph do not each need another directive. 2. Keep server data fetching in the server parent and pass its result to the client piece. Server-to-client props must be serializable by React. The docs also describe streaming with React's use API. 3. When an interactive wrapper must contain server-rendered UI, pass that UI from a Server Component through children or another prop. It remains server-rendered because the client wrapper does not import it into its module graph. 4. For a third-party hook-using component without the directive, add a small client wrapper. The official example uses app/carousel.tsx:
'use client'
import { Carousel } from 'acme-carousel'
export default Carousel
5. Put createContext and the provider in a Client Component, for example app/theme-provider.tsx. Render the provider from the layout, wrapping the needed children as deeply as possible in the tree. 6. Mark server-only modules with import 'server-only'. Importing such a module from a Client Component then produces a build-time error. Next.js handles that marker internally; installing server-only is optional, though a lint rule may require a declared dependency.
Limits and open questions
The directive defines a module boundary; it does not turn server-rendered content passed through props into a client import. This page establishes directive placement and composition, not the cause of every build error. It does not specify a required Next.js version for the fix or establish a general rule about async Client Components.
Not for: Pages Router data-fetching methods or a hydration mismatch investigation.
Sources
Checked
2026-11-17: read the Next.js Server and Client Components page, updated October 5, 2026; no command was run.
Started from a post by @Next.js (Vercel), packaged by the editor. Original post