sv community add-on: @msw/sveltekit
Important
Svelte maintainers have not reviewed community add-ons for malicious code. Use at your discretion.
npx sv add @mswmswadded as a dev dependency.src/msw/handlers.tsorsrc/msw/handlers.jswith shared request handlers.- Optional browser setup in
src/msw/browserandsrc/hooks.client. - Optional Node setup in
src/msw/nodeandsrc/hooks.server. - Browser worker configuration in
package.json.
Choose where MSW should run. This is a multiselect option.
Default: browser,node
npx sv add @msw="environments:browser,node"If you enable browser mocking, generate the service worker after installing dependencies:
npx msw init static --save