@mswjs/interceptors
Low-level HTTP request interception library for Node.js and browsers, used by MSW to mock fetch, XMLHttpRequest, and http.
Official Documentation ↗v0.30. Check the official docs for the latest API surface.Installation
npm install @mswjs/interceptorsMethods
No methods match this filter.
@mswjs/interceptors is low-level http request interception library for node.js and browsers, used by msw to mock fetch, xmlhttprequest, and http. This page documents the core methods, installation, and common usage patterns for the current stable release.
Installation
Install @mswjs/interceptors with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.
Core methods
The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v0.30 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.
Frequently asked questions
The faq section in the frontmatter answers the most common questions about @mswjs/interceptors, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.
FAQ
- Is this the same as MSW?
- MSW uses interceptors internally; use interceptors directly for lower-level control without MSW handlers.
- Which APIs can it intercept?
- fetch, XMLHttpRequest, http, https, and WebSocket in Node.js and browsers.
- Does it work in browsers?
- Yes. It patches global fetch and XMLHttpRequest; in Node it patches the http module.
Report a problem with this API docOpens a pre-filled issue on GitHub.