Skip to content

NextDiAdapter · Next.js server API

type NextDiAdapter = object;

Next.js server adapter instance created by createNextDi.

readonly getRootContainer: () => Container;

Returns the long-lived root server container.

Container


readonly getRequestContainer: () => Container;

Returns the current RSC render-scoped child container.

Container


readonly createRequestContainer: (providers?) => Container;

Creates a fresh child container manually, useful in route handlers or tests.

Parameter Type

providers?

readonly Provider[]

Container


readonly runWithRequestContainer: <TResult>(options) => Promise<Awaited<TResult>>;

Runs work inside a fresh child container and disposes it in a finally block. This does not bind the container to async context; use the callback argument, or di-craft/node when nested async code should call getRequestContainer().

Type Parameter

TResult

Parameter Type

options

RunWithRequestContainerOptions<TResult>

Promise<Awaited<TResult>>


readonly disposeRootContainer: () => Promise<void>;

Disposes cached instances owned by the root container.

Promise<void>