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
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() {
...
}
npm run test
# Don't forget to bump the version first
npm run release:server-only
npm run release:client-only
This package uses Node.js' Conditional Exports, hence the minimum required Node version is 12.