Skip to content

createNodeDi · Node.js API

function createNodeDi(options?): NodeDiAdapter;

Creates a Node.js adapter backed by AsyncLocalStorage.

Use this for explicit async scopes such as route handlers, server actions, jobs, and plain server code. React Server Components should keep using the Next adapter with React’s cache primitive.

Await all async work that reads the request container before the callback passed to runWithRequestContainer settles. The request container is disposed immediately after that callback settles. Deferred work, including callbacks registered with Next.js after, must enter a fresh request scope.

Parameter Type Description

options

CreateNodeDiOptions

Root and per-request providers for this adapter instance.

NodeDiAdapter

Helpers for root access and AsyncLocalStorage-backed request scopes.