Enable interactive UI
A component needs useState, event handlers, or other browser-side interactivity.
React 19+ · Directive
The 'use client' directive marks a module and its transitive dependencies as client code in React Server Components. It creates a server-client boundary so interactive components can run in the browser.
Place the directive at the beginning of a module to establish a server-to-client boundary. The module and its transitive dependencies become client code, enabling browser interactivity such as state and event handlers; values crossing from server-evaluated modules must be components or supported serializable props.
'use client';'use client';
import { useState } from 'react';
export default function Counter({ initial = 0 }: { initial?: number }) {
const [count, setCount] = useState(initial);
return <button onClick={() => setCount(count + 1)}>{count}</button>;
}This module is compiled as client code, so the component can use state and event handlers.
A component needs useState, event handlers, or other browser-side interactivity.
A server-rendered tree needs to include a browser-executed subtree.
A shared module contains dependencies that must be bundled for the browser.
It marks a module as client code for React Server Components. The module’s transitive dependencies are also evaluated on the client, and a compatible bundler treats the import as a server-client boundary.
Follow-up: Does every component used below a client component need its own directive? No; transitive dependencies are already client code, so another directive is unnecessary.
The directive must occur at the very beginning of the file, above imports or other code; comments are allowed before it. It has no effect when the module is imported from another client-rendered module.
Follow-up: Can a module without the directive still run on the client? Yes. A component can be evaluated on the client when it is a transitive dependency or is imported and used by a Client Component.
Server-evaluated modules may import values from a client module only when those values are React components or supported serializable prop values intended for a Client Component. This keeps the server-client boundary transferable.
Follow-up: Why does this restriction matter? The boundary must carry data that the client-side component model and compatible bundler can represent across environments.
use serverServer ComponentsClient ComponentsReact Server Components