Directives

Server-only module marker

Next.js recognizes this marker to prevent server-only modules from being imported into a client module graph. Does not remove private properties from returned values or enforce authorization. Source: https://nextjs.org/docs/app/getting-started/server-and-client-components. Staged reference; snippets are illustrative and not complete apps.

Formal Syntax & Structure

nextjs syntaxnextjs
import "server-only";

Working Example

Example Snippetnextjs
import "server-only";
Next.js Reference