A Next.js App or page decorator, React context object, and React hook to access Node.js HTTP server context when rendering components.
MIT License
A Next.js App
or page decorator, React context object, and React hook to access Node.js HTTP server context when rendering components.
Some uses:
To install next-server-context
with npm, run:
npm install next-server-context
Decorate either the entire Next.js app or individual pages using the function withServerContext
to be able to use the React hook useServerContext
.
Supported runtime environments:
^18.17.0 || >=20.4.0
.> 0.5%, not OperaMini all, not dead
.Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check
comment:
compilerOptions.allowJs
should be true
.compilerOptions.maxNodeModuleJsDepth
should be reasonably large, e.g. 10
.compilerOptions.module
should be "node16"
or "nodenext"
.The npm package next-server-context
features optimal JavaScript module design. It doesn’t have a main index module, so use deep imports from the ECMAScript modules that are exported via the package.json
field exports
: