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/iife/index.js"></script>
jsDelivr
1<script src="https://cdn.jsdelivr.net/npm/msw/lib/iife/index.js"></script>
Place the Service Worker
To copy the Service Worker into your public directory, use the npx msw init
command:
1npx msw init <PUBLIC_DIR>