# is-network-error

> Check if a value is a Fetch network error

Latest version **1.3.2** (published 2026-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-network-error
pnpm add is-network-error
yarn add is-network-error
bun add is-network-error
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2026-05-08 |
| First published | 2023-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 163 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | network, error, fetch, whatwg, detect, check, typeerror |

## Links

- npm: https://www.npmjs.com/package/is-network-error
- Repository: https://github.com/sindresorhus/is-network-error
- Homepage: https://github.com/sindresorhus/is-network-error#readme
- Issues: https://github.com/sindresorhus/is-network-error/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-network-error

## Alternatives

- [@sentry/react-native](https://npm.io/package/@sentry/react-native.md) — 2.6M weekly downloads
- [@ardatan/aggregate-error](https://npm.io/package/@ardatan/aggregate-error.md) — 708.1K weekly downloads
- [custom-error-generator](https://npm.io/package/custom-error-generator.md) — 2.0K weekly downloads
- [@technik-sde/prosemirror-recreate-transform](https://npm.io/package/@technik-sde/prosemirror-recreate-transform.md) — 1.5K weekly downloads
- [@suchipi/error-utils](https://npm.io/package/@suchipi/error-utils.md) — 78 weekly downloads

## Recent versions

- 1.3.2 (latest) — 2026-05-08
- 1.3.1 — 2026-02-26
- 1.3.0 — 2025-09-18
- 1.2.0 — 2025-09-16
- 1.1.0 — 2024-03-19
- 1.0.1 — 2024-01-04
- 1.0.0 — 2023-09-26

## README

# is-network-error

> Check if a value is a [Fetch network error](https://developer.mozilla.org/en-US/docs/Web/API/fetch#exceptions)

This can be useful when you want to do something specific when a network error happens without catching other Fetch-related errors.

Unfortunately, Fetch network errors are [not standardized](https://github.com/whatwg/fetch/issues/526) and differ among implementations. This package handles the differences across Node.js, Bun, Deno, and browsers.

For instance, [`p-retry`](https://github.com/sindresorhus/p-retry) uses this package to retry on network errors.

## Install

```sh
npm install is-network-error
```

## Usage

```js
import isNetworkError from 'is-network-error';

async function getUnicorns() {
	try {
		const response = await fetch('unicorns.json');
		return await response.json();
	} catch (error) {
		if (isNetworkError(error)) {
			return localStorage.getItem('…');
		}

		throw error;
	}
}

console.log(await getUnicorns());
```

## API

### `isNetworkError(value: unknown): value is TypeError`

Returns `true` if the given value is a Fetch network error, otherwise `false`.

This function acts as a type guard, narrowing the type to `TypeError` when it returns `true`.

---
_Source: https://npm.io/package/is-network-error · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
