Content-Length: 262154 | pFad | http://github.com/LorisSigrist/rsc-env

85 GitHub - LorisSigrist/rsc-env: A tiny package that uses export conditions do differentiate between server-component and non-server-component environments
Skip to content

A tiny package that uses export conditions do differentiate between server-component and non-server-component environments

License

Notifications You must be signed in to change notification settings

LorisSigrist/rsc-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A tiny package that uses export conditions do differentiate between server-component and non-server-component environments

Topics

Resources

License

Stars

Watchers

Forks









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/LorisSigrist/rsc-env

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy