- Introduction
- Getting started
- Philosophy
- Comparison
- Limitations
- Debugging runbook
- FAQ
- Basics
- Concepts
- Network behavior
- Integrations
- API
- CLI
- Best practices
- Recipes
- Cookies
- Query parameters
- Response patching
- Polling
- Streaming
- Network errors
- File uploads
- Responding with binary
- Custom worker script location
- Global response delay
- GraphQL query batching
- Higher-order resolver
- Keeping mocks in sync
- Merging Service Workers
- Mock GraphQL schema
- Remote Request Interception
- Using CDN
- Using custom "homepage" property
- Using local HTTPS
Using CDN
The best way to use Mock Service Worker is by installing it from the NPM registry. We highly encourage you to follow the Getting Started tutorial first before resorting to alternative installation methods:
Getting started
Three steps to get started with Mock Service Worker.
There are, however, other ways to install the library if you can’t use NPM.
CDN
You can add MSW to your application using a CDN. To do that, include a script tag that loads the IIFE build target (lib/iife/index.js
) of the library on your page.
Below, you can find some examples of how to include Mock Service Worker using popular CDN providers.
unpkg
<script src="https://unpkg.com/msw/lib/iife/index.js"></script>
jsDelivr
<script src="https://cdn.jsdelivr.net/npm/msw/lib/iife/index.js"></script>