> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/unjs/ofetch/llms.txt
> Use this file to discover all available pages before exploring further.

# ofetch

> A better fetch API that works on Node.js, browser, and workers with smart defaults and powerful features

## What is ofetch?

ofetch is a modern HTTP client that provides a better fetch API experience. It works seamlessly across Node.js, browser, and worker environments with intelligent defaults and powerful features that make HTTP requests simpler and more reliable.

## Key features

ofetch enhances the standard fetch API with features designed for modern development:

* **Smart JSON handling** - Automatically parses JSON responses and stringifies request bodies
* **Auto retry** - Automatically retries failed requests with configurable status codes
* **Better errors** - Throws friendly error messages with compact stack traces and parsed error bodies
* **Type safety** - Full TypeScript support with response type inference
* **Interceptors** - Lifecycle hooks for requests and responses
* **Timeout support** - Built-in timeout with automatic abort
* **Query params** - Easy query string management with the `query` option
* **Base URL** - Set base URLs for cleaner request paths
* **Proxy support** - Works with HTTP proxies in Node.js, Bun, and Deno
* **SSE streaming** - Handle server-sent events with response streams

## Get started

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/quickstart">
    Get up and running with ofetch in minutes
  </Card>

  <Card title="Installation" icon="download" href="/installation">
    Install ofetch in your project
  </Card>
</CardGroup>

## Why ofetch?

The standard fetch API is powerful but requires boilerplate for common tasks. ofetch eliminates that friction:

```javascript theme={null}
// Standard fetch requires manual JSON handling
const response = await fetch('/api/users', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ name: 'John' })
});
const data = await response.json();

// ofetch handles it automatically
const data = await ofetch('/api/users', {
  method: 'POST',
  body: { name: 'John' }
});
```

ofetch automatically:

* Parses JSON responses
* Stringifies request bodies
* Sets appropriate headers
* Throws errors for failed requests
* Retries on network failures
