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

@naverpay/eslint-plugin-use-client

v0.0.2

Published

provides a rule to determine if a react server component needs the use client directive

Readme

@naverpay/eslint-plugin-use-client

ESLint plugin that automatically detects when React Server Components need the 'use client' directive

This ESLint plugin provides rules to determine if a React Server Component needs the 'use client' directive based on the usage of client-side features like React hooks, browser APIs, and event handlers.

Features

  • 🔍 Automatic Detection: Detects when client-side features are used in React components
  • 🔧 Auto-fix: Automatically adds 'use client' directive when needed
  • ⚙️ Configurable: Supports ignore paths for specific files or patterns
  • 🚀 Next.js Ready: Perfect for Next.js 13+ App Router with React Server Components

Installation

npm install @naverpay/eslint-plugin-use-client --save-dev
# or
yarn add @naverpay/eslint-plugin-use-client --dev
# or
pnpm add @naverpay/eslint-plugin-use-client --save-dev

Usage

ESLint Config (Flat Config)

// eslint.config.js
import useClientPlugin from '@naverpay/eslint-plugin-use-client'

export default [
  {
    plugins: {
      'use-client': useClientPlugin
    },
    rules: {
      'use-client/use-client-hook': 'error',
      'use-client/browser-api': 'error',
      'use-client/event-handler': 'error'
    }
  }
]

Legacy ESLint Config

{
  "plugins": ["@naverpay/eslint-plugin-use-client"],
  "rules": {
    "@naverpay/use-client/use-client-hook": "error",
    "@naverpay/use-client/browser-api": "error",
    "@naverpay/use-client/event-handler": "error"
  }
}

Rules

use-client-hook

Detects when React hooks are used in components and requires 'use client' directive.

❌ Incorrect

import { useState } from 'react'

function MyComponent() {
  const [count, setCount] = useState(0) // Error: React hook detected
  
  return <div>{count}</div>
}

✅ Correct

'use client'

import { useState } from 'react'

function MyComponent() {
  const [count, setCount] = useState(0)
  
  return <div>{count}</div>
}

browser-api

Detects when browser APIs (like window, document, localStorage, etc.) are used and requires 'use client' directive.

❌ Incorrect

function MyComponent() {
  const handleClick = () => {
    window.alert('Hello') // Error: Browser API detected
  }
  
  return <button onClick={handleClick}>Click me</button>
}

✅ Correct

'use client'

function MyComponent() {
  const handleClick = () => {
    window.alert('Hello')
  }
  
  return <button onClick={handleClick}>Click me</button>
}

event-handler

Detects when HTML elements have event handlers (onClick, onChange, etc.) and requires 'use client' directive.

❌ Incorrect

function MyComponent() {
  return (
    <button onClick={() => console.log('clicked')}> {/* Error: Event handler detected */}
      Click me
    </button>
  )
}

✅ Correct

'use client'

function MyComponent() {
  return (
    <button onClick={() => console.log('clicked')}>
      Click me
    </button>
  )
}

Configuration

Each rule supports an ignorePath option to exclude specific files or patterns:

{
  rules: {
    'use-client/use-client-hook': ['error', {
      ignorePath: [
        'src/components/server/**',
        '**/*.server.tsx'
      ]
    }],
    'use-client/browser-api': ['error', {
      ignorePath: 'src/lib/**'
    }],
    'use-client/event-handler': ['error']
  }
}

Supported React Hooks

The plugin detects all React hooks including:

  • Built-in hooks: useState, useEffect, useContext, etc.
  • Custom hooks: any function starting with use followed by a capital letter
  • React namespace hooks: React.useState, React.useEffect, etc.

Why Use This Plugin?

When working with Next.js 13+ App Router and React Server Components, it's crucial to properly mark components that use client-side features with the 'use client' directive. This plugin helps by:

  1. Preventing Runtime Errors: Automatically catches when client-side code is used in server components
  2. Improving Developer Experience: No need to manually remember when to add 'use client'
  3. Maintaining Performance: Ensures only necessary components are marked as client components
  4. Code Consistency: Enforces consistent usage of 'use client' across your codebase

License

MIT © NaverPayDev