Plugin
plugins: [pluginMsw()]Officialv5.0.11kubb >=5.8.0node >=22
MSW
@kubb/plugin-msw
Generates MSW request handlers from your OpenAPI spec so you can mock the API in tests and during local development.
kubb add plugin-msw
mswmock-service-workerapi-mockingmockstestingcodegenopenapi
- Downloads286.8K/ monthnpm, last 30 days
- GitHub stars8kubb-labs/plugins
- Unpacked size183.5kBv5.0.11 on npm
- Latest release42m agov5.0.11 · Oct 13, 2026
Generates typed MSW request handlers from your OpenAPI spec, one per operation. Use them to mock the API in tests and during local development.
Each handler returns the data you pass to it. With parser: 'faker', it falls back to mock data from @kubb/plugin-faker when you pass none.
Installation
bun add -d @kubb/plugin-mswpnpm add -D @kubb/plugin-mswnpm install --save-dev @kubb/plugin-mswyarn add -D @kubb/plugin-mswOr run kubb add plugin-msw to install the version the Kubb registry pins and add pluginMsw() to kubb.config.ts.
Setup
- Add
@kubb/plugin-ts. - Add
@kubb/plugin-fakerwhen you setparser: 'faker'. The defaultdataparser does not need it. - Install MSW v2 or higher in the app that uses the generated code.
Options worth knowing
parsersets where the response body comes from:data(default) orfaker.handlerswrites ahandlers.tsfile that exports every handler, ready to spread intosetupServerorsetupWorker.baseURLis prepended to the path each handler matches.
Dependencies
No extension dependencies.