Skip to content

Use the controller with Node

The controller does not require a browser worker. Any runtime that can list handlers and reset handlers fits the contract.

interface MswRuntimeController {
listHandlers(): readonly MswAnyHandler[];
resetHandlers(...nextHandlers: MswAnyHandler[]): void;
}

setupServer satisfies this pattern, which is why the Node example can reuse the same controller model.

Run the example CLI:

Terminal window
pnpm dev:example-node

Available commands include:

  • list
  • user
  • projects
  • toggle 1
  • all off
  • exit

Disabled state is persisted to apps/example-node/.msw-panel-state.json.

The controller only depends on a runtime that can list handlers and reset handlers. That keeps the package useful outside the browser without special Node-specific UI logic.