Registry / web-framework / rollup-plugin-use-client

rollup-plugin-use-client

JSON →
library1.4.0jsnpmunverified

Rollup plugin (v1.4.0) that re-adds the 'use client' directive stripped by Rollup during bundling, essential for React Server Components. Released December 2022, maintained on GitHub. Key differentiator: solves the specific problem of directive removal in Rollup, with configurable directive string and simple ESM API. Unmaintained since 2022.

npm install rollup-plugin-use-client
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-USE-
R
rollup-plugin-use-client
web-frameworkjavascriptv1.4.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useClient
import useClient from 'rollup-plugin-use-client'
import { useClient } from 'rollup-plugin-use-client'
Default export only; named import will result in undefined.
useClient
const useClient = require('rollup-plugin-use-client')
const { useClient } = require('rollup-plugin-use-client')
CommonJS require returns the default export directly.
useClient
import useClient from 'rollup-plugin-use-client'
import * as useClient from 'rollup-plugin-use-client'
Namespace import is not the default; use default import.

Shows basic setup to add 'use client' directive in Rollup config.

// Install: npm install --save-dev rollup-plugin-use-client import useClient from 'rollup-plugin-use-client'; export default { input: 'src/index.js', output: { file: 'dist/bundle.js', format: 'esm' }, plugins: [ useClient() ] };
Debug
Known issues
gotchaPlugin adds 'use client' to top of every file processed; in single-bundle output, the directive may be added to the entire bundle, causing unintended behavior.
fix
Ensure code splitting is enabled or only apply plugin to specific files via include/exclude options.
affects: >=1.0.0
gotchaThe directive is inserted as a string literal at the top of the module; if used with plugins that expect the directive to be a comment or statement, it may not be recognized correctly.
fix
Use compatible bundler or check target runtime support.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: useClient is not a function
Imported useClient as a named export instead of default.
fix
Change to: import useClient from 'rollup-plugin-use-client'
'use client' directive not added to output
Plugin not included in Rollup plugins array or output file not covered.
fix
Ensure plugin is added to plugins array: plugins: [useClient()]
Upgrade
Version history
1.4.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
rollup-plugin-use-client — npm install rollup-plugin-use-client · libregistry