Skip to content

jaydenseric/next-server-context

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

next-server-context

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:

  • Setting the HTTP response status code for the server side rendered page according to GraphQL query results in components.
  • Isomorphically accessing cookies within components.

Installation

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.

Requirements

Supported runtime environments:

Projects must configure TypeScript to use types from the ECMAScript modules that have a // @ts-check comment:

Exports

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:

About

A Next.js App or page decorator, React context object, and React hook to access Node.js HTTP server context when rendering components.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project