Interactive controls
A component uses useState or useReducer for local interactive state.
Next.js 16+ · Directive
'use client' marks a module as a client entry point in the App Router. Use it for interactive UI that needs state, event handlers, or browser APIs, while keeping boundary props serializable.
Place 'use client' as the first statement in a module, before imports, to make its exports entry points for the client side. The boundary applies to the whole module: imported code and rendered descendants join the client graph, while values passed from server components must be serializable.
'use client'// app/ui/counter.tsx
'use client'
import { useState } from 'react'
export default function Counter() {
const [count, setCount] = useState(0)
return (
<button onClick={() => setCount(count + 1)}>
Count: {count}
</button>
)
}This client entry point enables state and event handling for the counter.
A component uses useState or useReducer for local interactive state.
A component registers click, input, or submit handlers.
A component reads browser-only APIs such as window or navigator.
A server-rendered page embeds a focused interactive widget.
It declares a client entry point for components that need client-side JavaScript, such as state, event handlers, or browser APIs. It also establishes the server/client boundary for that module.
Follow-up: What does the boundary include? The module's imports and directly rendered client subtree become part of the client module graph, so place it narrowly to control browser JavaScript.
It must be the first statement in the file, before imports. The directive applies to the entire module rather than to one component or function.
Follow-up: Can it be placed inside a component? No; the page documents that inline placement is invalid, so use a separate module boundary instead.
Props passed across the boundary must be serializable so React can send them from the server to the client. State and event handlers can live in the client component itself.
Follow-up: Can a server component pass an event-handler function directly? No, ordinary functions cannot cross this boundary; pass serializable data and handle interaction on the client.
Server ComponentsClient Componentsserver and client boundaryserializable propsuse server