Mock Service Worker
  1. Recipes
  2. Usage with CDN

Usage with CDN

Pick a suitable CDN that can serve NPM modules and include the respective script in your page. See the examples of how to integrate Mock Service Worker using a few popular CDNs below.

unpkg

1<script src="https://unpkg.com/msw/lib/index.js"></script>

jsDelivr

1<script src="https://cdn.jsdelivr.net/npm/msw/lib/index.js"></script>

Place the Service Worker

To copy the Service Worker into your public directory, use the npx msw init command:

1$ npx msw init <PUBLIC_DIR>