packages/msw/README.md
Mock Service Worker (MSW) integration for Clerk component scenarios.
Instead of manually creating handlers for every Clerk API endpoint, this package provides:
clerkHandlers) - Automatically respond to all standard Clerk session management requestsUserService) - Pre-configured user personas you can select fromEnvironmentService) - Pre-configured Clerk environment typesYou just select the user and environment you want, set the state, and MSW handles the rest!
This package is part of the monorepo and should be added as a workspace dependency:
{
"dependencies": {
"@examples/msw": "workspace:*"
}
}
Each consuming app needs to generate the mockServiceWorker.js file in its public directory:
# From your app directory (e.g., apps/previews)
pnpx msw init public --save
This creates the service worker file that MSW uses to intercept network requests in the browser.
This package uses TypeScript source files directly (no build step required).