A polyfill-aware module that returns the native fetch/Request/Headers API if available in the runtime, otherwise falls back to the undici module. Version 4.0.2 is the current stable release; the package has frequent updates aligned with undici releases. Key differentiator: unlike node-fetch, it uses WHATWG streams for type compatibility and provides a seamless way to write isomorphic code without heavy-handed bundler overrides. Ships TypeScript types. Requires undici as a peer dependency.
npm install native-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates using the fetch export from native-fetch with async/await to make a GET request and parse JSON response.
Switch to ESM imports: `import { fetch } from 'native-fetch'`Update undici to v6+ if using native-fetch v4.
Test both paths if you need consistent behavior across environments.
Import or polyfill AbortController separately.
Change default import to named import: `import { fetch } from 'native-fetch'`Run `npm install native-fetch undici`
Add "type": "module" to your package.json or use .mjs extension.
Update to v4: `npm install native-fetch@latest`
Use named import: `import { fetch } from 'native-fetch'`