Overview
ofetch.native() provides a shortcut to the native fetch API, allowing you to use standard fetch when you don’t need ofetch’s additional features.
Basic Usage
When to Use
Use ofetch.native() when you:
- Need standard fetch behavior without ofetch enhancements
- Want to process the response manually
- Need compatibility with code expecting native fetch
- Want to avoid automatic JSON parsing or error handling
How It Works
From src/fetch.ts:266:
This is a direct passthrough to the underlying fetch implementation configured for the ofetch instance.
Comparison
ofetch (default)
ofetch.native()
ofetch.raw()
Common Use Cases
Manual Response Processing
Streaming Response
Custom Content Type Handling
Progressive Enhancement
With Custom Instances
ofetch.native() bypasses ofetch’s automatic JSON parsing, error handling, and retry logic. You’ll need to handle these manually.
Implementation Details
From src/index.ts:9-11:
The fetch wrapper:
- Uses
globalThis.fetch if available (browser, modern Node.js)
- Forwards all arguments to the native fetch
- Throws an error if fetch is not supported
Standard Fetch API
ofetch.native() supports all standard fetch options:
TypeScript
From src/types.ts:14:
native is typed as the standard Fetch type: