Skip to main content

ServerSsrContext

import { ServerSsrContext } from '@dr.pogodin/react-utils';

The ServerSsrContext class extends SsrContext class from the React Global State library; it is used by React Utils server() factory as a part of SSR setup.

Generic Parameters

  • StateT — The type of global state object.

Properties

  • chunkGroupsChunkGroupsT

  • chunksstring[] — Defaults empty array.

  • redirectTostring | undefined — Undefined by default; if it is set by the app during SSR, the server will trigger redirect to this URL, instead of serving the generated HTML markup. Note, it will use status property (below) to set the redirect code, thus it also should be set to appropriate code to perform a redirect.

  • reqRequest — ExpressJS request being handled.

  • statusnumber — HTTP status for the response. Defaults 200 (OK).

Methods

constructor()

constructor(req: Request, chunkGroups: ChunkGroupsT, initialState?: StateT)

Creates a new ServerSsrContext instance.

Arguments

  • resRequest
  • chunkGroupsChunkGroupsT
  • initialStateStateT — Optional. Initial global state value.