Skip to main content

Install ofetch

You can install ofetch using your preferred package manager:
npm install ofetch

Environment support

ofetch works across multiple JavaScript runtimes:
  • Node.js - Version 18 and above (uses native fetch)
  • Browsers - All modern browsers with fetch support
  • Workers - Cloudflare Workers, Service Workers, Web Workers
  • Bun - Full support with native fetch
  • Deno - Full support with native fetch
ofetch uses the native fetch API available in your environment. For Node.js versions below 18, you may need a fetch polyfill.

TypeScript support

ofetch is written in TypeScript and includes type definitions out of the box. No additional @types packages are required.
import { ofetch } from 'ofetch';

// Response types are automatically inferred
interface User {
  id: number;
  name: string;
}

const user = await ofetch<User>('/api/user/1');
// user.id and user.name are fully typed

Next steps

Now that you have ofetch installed, learn how to make your first request in the quickstart guide.

Build docs developers (and LLMs) love