SE

Server Only

server-only

This is a marker package to indicate that a module can only be used in Server Components.

Utilities
react
server-only
Utilities
javascript
npm
frontend
open source
ui
library
web
Stars
1
Weekly
0
Open issues
0
Bundle
~60 kB

Installation

npm install server-only

Code example

import { useServerOnly } from "server-only";

export function Example() {
  const value = useServerOnly();
  return <p>{String(value)}</p>;
}

Pros & cons

Pros

  • Actively maintained by sebmarkbage
  • 0 weekly downloads. Battle tested
  • MIT licensed

Considerations

  • Adds roughly ~60 kB to your bundle
  • Needs client-only rendering in SSR frameworks
  • Not supported in React Native
  • 0 open issues on GitHub

FAQs

Alternatives & similar libraries