rsc-env
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

RSC-ENV

Inspired by the brilliant esm-env

Uses export conditions to return if the current environment is react-server or not. Bundlers can statically determine the environment at build time & remove dead code.

This is useful for writing utility functions that may be called by either server or client components.

Example

npm install rsc-env
// utils/shared.ts
import { rsc } from "rsc-env";

// This code will be treeshaken from client-component builds
if(rsc) console.log("I'm running in a server component")

License

MIT

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i rsc-env

      Weekly Downloads

      647

      Version

      0.0.2

      License

      MIT

      Unpacked Size

      2.73 kB

      Total Files

      6

      Last publish

      Collaborators

      • lurmwoch