variable servicesContext
Since 0.2.0

Key holding the kernel IServiceRegistry for the current request.

Always set by the plugin, so context.get(servicesContext) never returns the null default on a request served through the SSR catch-all. The | null in the type exists only because the key needs a default at all — React Router's get() throws for an unset key that has none.

Examples

Example 1

import { servicesContext } from '@setu-ts/react-router-plugin';
import { CAPABILITIES, type ILogger } from '@setu-ts/common';

export async function loader({ context }: Route.LoaderArgs) {
  const services = context.get(servicesContext);
  services?.get<ILogger>(CAPABILITIES.LOGGER).info('ssr loader');
  return { ok: true };
}

Type

RouterContextKey<IServiceRegistry | null>

Usage

import { servicesContext } from "react-router-plugin/src/index.ts";