Skip to content

gspot/require-server-only

Checks that a selected server module imports “server-only” or declares “use server”.

No config turns it on; turn it on in your ESLint config.

A server-only marker lets Next.js reject client imports of a module that uses private server capabilities.

Add import “server-only” to the imports. Use “use server” only for a module that follows the Server Actions contract. If the file is not server code, remove it from the files this rule selects.

A selected server module containing export const secret = 1; reports missing. With the server-only package installed, add import "server-only"; before that declaration.

This rule has no options.