Skip to content

mswjs/sveltekit

Repository files navigation

sv community add-on: @msw/sveltekit

Important

Svelte maintainers have not reviewed community add-ons for malicious code. Use at your discretion.

Usage

npx sv add @msw

What you get

  • msw added as a dev dependency.
  • src/msw/handlers.ts or src/msw/handlers.js with shared request handlers.
  • Optional browser setup in src/msw/browser and src/hooks.client.
  • Optional Node setup in src/msw/node and src/hooks.server.
  • Browser worker configuration in package.json.

Options

environments

Choose where MSW should run. This is a multiselect option.

Default: browser,node

npx sv add @msw="environments:browser,node"

Browser worker

If you enable browser mocking, generate the service worker after installing dependencies:

npx msw init static --save

About

Mock API requests in SvelteKit with Mock Service Worker.

Topics

Resources

Contributing

Stars

2 stars

Watchers

0 watching

Forks

Contributors