client-only-module

0.0.1 • Public • Published

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.

/client-only-module/

    Package Sidebar

    Install

    npm i client-only-module

    Weekly Downloads

    5

    Version

    0.0.1

    License

    MIT

    Unpacked Size

    2.35 kB

    Total Files

    4

    Last publish

    Collaborators

    • d_e_v.e_s_h