'use client'
The directive that marks a module as the entry point to client code, so it and its imports are sent to the browser.
In more detail
Place it at the very top of a file. It marks a boundary, not a single component: everything imported below it is client code. Push it as far down the tree as you can so most of the page stays on the server.
Example
'use client';
import { useState } from 'react';Related terms
- Client Component — A component whose code is also sent to the browser so it can use state, effects and event handlers.
- directive — A string written at the top of a file or function, such as 'use client', that tells React or Next.js how to treat that code.
- 'use server' — The directive that marks async functions as Server Actions, callable from the client but always run on the server.
Taught in
- Server Components: Async Execution & Constraints — Next.js 15 & Modern App Router Architecture
- Client Components: use client & Hydration Models — Next.js 15 & Modern App Router Architecture
- Component Tree Composition: Interleaving RSC & Client — Next.js 15 & Modern App Router Architecture
- Error Boundaries: Nested error.tsx & Reset Logic — Next.js 15 & Modern App Router Architecture