is-redirect is a lightweight, focused utility package for JavaScript and TypeScript environments that efficiently determines if a given numeric HTTP status code falls within the 3xx redirection range. The current stable version is 2.0.0. As part of Sindre Sorhus's collection of focused utilities, it follows a pragmatic release cadence, with major versions typically signaling significant breaking changes, such as the recent transition to pure ESM. Its primary differentiator is its singular focus and minimal footprint, providing a reliable, dependency-free check for redirect status codes without including additional HTTP client or server logic. It serves as a fundamental building block for applications that need to interpret HTTP responses, such as proxies, web scrapers, or API clients, ensuring correct handling of redirect flows.
npm install is-redirectVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to use `is-redirect` to categorize different HTTP status codes, highlighting its primary function within a broader status checking logic.
Migrate your project to use ESM imports (`import isRedirect from 'is-redirect';`) or ensure your consuming module is also ESM. For Node.js, this often involves setting `"type": "module"` in your `package.json` or using `.mjs` file extensions.
Upgrade your Node.js environment to version 12 or newer. If you must support older Node.js versions, you will need to stick to `is-redirect@1.x`.
For comprehensive HTTP status code handling beyond 3xx redirects, integrate `is-redirect` with other status code checking utilities or custom logic for different HTTP ranges (e.g., `is-success`, `is-server-error`).
Change your import statement to `import isRedirect from 'is-redirect';` and ensure your file/project is configured for ESM (e.g., `"type": "module"` in `package.json`).
Either rename your file to `.mjs` or add `"type": "module"` to your project's `package.json` to enable ESM for `.js` files. Alternatively, if your project needs to remain CommonJS, downgrade `is-redirect` to version 1.x.
No dependency data recorded yet.