server-only-module
v0.0.1
Published
This is a marker package to indicate that a module can only be used in a server environment.
Downloads
8
Readme
Framework-agnostic way to mark JavaScript modules as Server or Client only.
Inspired by server-only and client-only.
Note: If you're already using a React framework, there's no need of using this package, just use server-only or client-only as indicated here: Rendering: Composition Patterns | Next.js - Keeping Server-only Code out of the Client Environment
Usage
npm install server-only-module
# or
npm install client-only-module
Use it in your modules:
import 'server-only-module';
// or
import 'client-only-module';
async function yourCode() {
...
}
Running Tests
npm run test
Publishing to npm
# Don't forget to bump the version first
npm run release:server-only
npm run release:client-only
Minor Note
This package uses Node.js' Conditional Exports, hence the minimum required Node version is 12.