Next.js stability

no-server-only-in-client

Forbid Node-core / DB-driver imports from `"use client"` and `*.client.{ts,tsx}` files.

AI-generated React components routinely `import fs from "fs"` or `import { PrismaClient } from "@prisma/client"` inside a client component. Webpack/Turbopack either crash the build or ship a bundled stub that fails at runtime. Move the call to a server boundary (route handler, server action, server component).

Behavior

  • Fixable: No.
  • Suggestions: No.

Examples

Bad:

'use client';
import fs from 'fs';

Good:

'use server';
import fs from 'fs';

Related rules

Use it

Enable no-server-only-in-client in your eslint.config.js:

import deslint from '@deslint/eslint-plugin';

export default [
  {
    plugins: { deslint },
    rules: {
      'deslint/no-server-only-in-client': 'error',
    },
  },
];

Found a false positive? Report it on GitHub →

Back to all rules