npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

biome-plugin-no-use-client

v0.2.17

Published

Biome GritQL plugin that errors when Next.js page/layout files contain a `use client` directive.

Downloads

41

Readme

biome-plugin-no-use-client

A Biome GritQL plugin that detects and errors when Next.js page or layout files contain a "use client" directive.

Why?

In Next.js App Router, page and layout files should typically be Server Components by default. Adding "use client" to these files can negatively impact performance and should generally be avoided. This plugin helps enforce this best practice by flagging such usage.

Installation

npm install --save-dev biome-plugin-no-use-client
# or
pnpm add -D biome-plugin-no-use-client
# or
yarn add -D biome-plugin-no-use-client

Usage

Add the plugin configuration to your biome.json or biome.jsonc configuration file:

Recommended Configuration

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "extends": ["biome-plugin-no-use-client"],
  "linter": {
    "enabled": true
  }
}

Alternative Explicit Configuration

You can also use the explicit path if you prefer:

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "extends": ["biome-plugin-no-use-client/next"],
  "linter": {
    "enabled": true
  }
}

Both configurations are equivalent and will automatically scope the plugin to only run on Next.js page and layout files for optimal performance.

Manual Configuration (Advanced)

If you need full control over the configuration, you can also configure the plugin manually:

{
  "$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
  "linter": {
    "enabled": true
  },
  "overrides": [
    {
      "includes": [
        "**/app/**/page.js",
        "**/app/**/page.jsx",
        "**/app/**/page.ts",
        "**/app/**/page.tsx",
        "**/app/**/layout.js",
        "**/app/**/layout.jsx",
        "**/app/**/layout.ts",
        "**/app/**/layout.tsx",
        "**/src/app/**/page.js",
        "**/src/app/**/page.jsx",
        "**/src/app/**/page.ts",
        "**/src/app/**/page.tsx",
        "**/src/app/**/layout.js",
        "**/src/app/**/layout.jsx",
        "**/src/app/**/layout.ts",
        "**/src/app/**/layout.tsx"
      ],
      "plugins": [
        "./node_modules/biome-plugin-no-use-client/src/no-use-client-on-page.grit"
      ]
    }
  ]
}

What it detects

The plugin will error on the following files when they contain "use client" or 'use client' directives:

  • **/page.js
  • **/page.jsx
  • **/page.ts
  • **/page.tsx
  • **/layout.js
  • **/layout.jsx
  • **/layout.ts
  • **/layout.tsx

Examples

❌ Will error

// app/page.tsx
"use client";

export default function Page() {
  return <div>Hello World</div>;
}
// app/dashboard/layout.tsx
'use client';

export default function Layout({ children }: { children: React.ReactNode }) {
  return <div>{children}</div>;
}

✅ Will not error

// app/page.tsx - No directive (Server Component by default)
export default function Page() {
  return <div>Hello World</div>;
}
// components/Button.tsx - Non-page/layout file
"use client";

export default function Button() {
  return <button>Click me</button>;
}

Error message

When the plugin detects a violation, it will show:

Remove the 'use client' directive.

Notes

  • The plugin only checks files that match the page/layout naming pattern
  • Component files and other non-page/layout files are not affected
  • Both single and double quotes are detected
  • The directive must appear as a top-level string literal

Testing

This project includes comprehensive testing infrastructure optimized for performance:

Test Types

  • Unit Tests (tests/unit.test.ts): Fast tests that validate the GritQL pattern logic
  • Integration Tests (tests/integration.test.ts): End-to-end tests using shared test environment

Test Fixtures

Test fixtures are available in tests/fixtures/:

  • valid/: Files that should NOT trigger the rule
  • invalid/: Files that SHOULD trigger the rule
  • edge-cases/: Complex scenarios and boundary conditions

Running Tests

# Run all tests (fast - ~1.5 seconds)
pnpm test

# Run with watch mode for development
pnpm test:watch

Performance Optimizations

The test suite uses several optimizations:

  • Shared test environment: Single npm install shared across all integration tests
  • Fixture caching: Test fixture content is preloaded and cached
  • Optimized cleanup: Minimal file operations between tests

Contributing

When contributing:

  1. Add test fixtures in tests/fixtures/ for new scenarios
  2. Update unit tests for pattern logic changes
  3. Add integration tests for new file types or edge cases
  4. Run tests to ensure no regressions

License

MIT