
Mock Service Worker
Mock Service Worker (MSW) is a free, open-source API mocking library for browser and Node.js applications.
What Mock Service Worker is
Mock Service Worker (MSW) is a free, open-source API mocking library for browser and Node.js applications. It intercepts outgoing requests so developers can observe them and return mocked responses through the Fetch API. MSW supports HTTP and REST, GraphQL queries and mutations, Server-Sent Events, and WebSocket APIs. The same client-agnostic handlers can be reused across development, integration and end-to-end testing, Storybook, and live demos. It works with native fetch and clients including Axios, React Query, and Apollo. In browsers, MSW registers a Service Worker at the network level, and the application must serve that worker script. In Node.js, setupServer enables mocking in an application process or test runner. Integration guidance covers Cloudflare, React Native, Storybook, Vite, and Vitest; listed extensions include Playwright, Cloudflare workerd, and SvelteKit. Browser and Node.js interception have defined boundaries, including Firefox XMLHttpRequest behavior and direct net.connect calls.
Good
- Free and open-source
- Reusable mocks across environments
- Supports REST, GraphQL, SSE, and WebSockets
- Works with fetch, Axios, React Query, and Apollo
- Browser and Node.js integrations
Watch out
- Firefox omits page XMLHttpRequest notifications
- Cannot intercept direct net.connect requests
- GraphQL subscriptions are not yet supported
- Browser worker script must be served
Who it suits
MSW suits developers who need reusable request mocks across browser and Node.js workflows. It is useful for testing, Storybook, development, and demonstrations involving supported protocols and clients.
Verdict
MSW provides one mocking approach across application and test environments, with broad protocol and client support. Its Service Worker and Node.js boundaries should be checked against your request paths.
The facts
Each one read from Mock Service Worker's own pages, with the date it was checked.
What it does
- Additional integrations
- The MSW organization lists extensions for Playwright, Storybook, Cloudflare workerd, and SvelteKit.checked 30 Sep 2026
- Client compatibility
- The documentation names native fetch and third-party clients including Axios, React Query, and Apollo as supported request clients.checked 30 Sep 2026
- Learning resources
- The documentation says its official Egghead courses require a paid subscription and help support the project.checked 30 Sep 2026
- Limitations
- MSW's GraphQL documentation says it supports queries and mutations, while subscriptions are described as coming in the future.checked 30 Sep 2026
- Network APIs
- MSW supports mocking REST, GraphQL, Server-Sent Events, and WebSocket APIs.checked 30 Sep 2026
- Network standards
- MSW uses the Fetch API to handle intercepted requests and construct mocked responses, including requests made with other clients.checked 30 Sep 2026
- Node integration
- In Node.js, MSW intercepts raw socket connections before they reach the network code written in C.checked 30 Sep 2026
- Node.js integration
- In Node.js, MSW provides setupServer for enabling API mocking in an application process or test runner.checked 30 Sep 2026
- Node.js limitation
- MSW cannot intercept requests made directly through net.connect() or net.createConnection(), which some libraries use.checked 30 Sep 2026
- Open source
- The project describes MSW as open-source and free to try.checked 30 Sep 2026
- Paid learning
- The documentation says its official Egghead courses require a paid subscription.checked 30 Sep 2026
- Protocols
- MSW supports mocking HTTP, GraphQL, Server-Sent Events, and WebSocket APIs.checked 30 Sep 2026
- Purpose
- Mock Service Worker (MSW) is an API mocking library for browser and Node.js that intercepts outgoing requests so developers can observe and respond with mocked responses.checked 30 Sep 2026
- Request clients
- MSW works with native fetch and third-party clients such as Axios, React Query, and Apollo.checked 30 Sep 2026
- Reusable mocks
- The same mock handlers can be reused for development, integration and end-to-end testing, Storybook, and live demos.checked 30 Sep 2026
- Shared mocks
- The same client-agnostic mocks can be reused across frameworks, tools, and environments, including development, integration and end-to-end testing, Storybook, and live demos.checked 30 Sep 2026
- Support
- The quick start directs users to a debugging runbook, MSW Discord, and GitHub Discussions for help.checked 30 Sep 2026
- Tool integrations
- The site provides integration guides for Cloudflare, React Native, Storybook, Vite, and Vitest, as well as browser and Node.js.checked 30 Sep 2026
- What it does
- MSW is an API mocking library for browser and Node.js that intercepts outgoing requests so they can be observed and answered with mocked responses.checked 30 Sep 2026
Where it runs
- Browser integration
- In browsers, MSW uses the Service Worker API to intercept requests at the network level.checked 30 Sep 2026
- Browser limitation
- Because browser interception relies on the Service Worker API, browser-specific limitations apply; the docs also state that Firefox does not notify the worker about page XMLHttpRequest requests.checked 30 Sep 2026
Alternatives to Mock Service Worker
- 1
Mockzilla
Free planOpen sourceWebAPILinuxmacOS8.1From $10 a month - 2

Beeceptor
Free planWebAPILinuxmacOS7.9From $10 a month - 3
Mockfly
Free planWebAPIExtensionLinux7.4From €150 a year - 4

Microcks
Free planWebAPIExtensionLinux7.2Free plan - 5
MockAPI
Free planWebAPI7.2From $35 a year - 6
Knockout API
Free planWebAPI7.0From $10 a month
