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.

In more detail

Directives must come before any imports or other code in the file or function. Tools read them at build time to decide where the code may run or how it is treated.

Example

React defines 'use client' and 'use server'; Next.js adds 'use cache'.

Related terms

Taught in

References