unjs

unjs/ofetch

TypeScript MIT Web Dev alpha-version-branching

😱 A better fetch API. Works everywhere.

5.3k stars
181 forks
active
GitHub +7 / week

5.3k

Stars

181

Forks

107

Open issues

30

Contributors

v1.5.1 01 Nov 2025

AI Analysis

ofetch is a lightweight HTTP client that improves upon the standard Fetch API with smart JSON parsing, automatic retries, and unified error handling. It works across Node.js, browsers, and worker environments, making it particularly valuable for isomorphic JavaScript projects that need consistent fetch behavior across multiple runtimes. Best suited for developers building universal JavaScript applications who want to reduce boilerplate around HTTP requests.

Web Dev Library Discovery value: 6/10
Documentation 8/10
Activity 10/10
Community 8/10
Code quality 7/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 8/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

http-client fetch-api isomorphic-javascript typescript error-handling
Actively maintained Well documented MIT licensed Popular Beginner friendly Production ready
Deep Analysis · Based on README and public signals
2w ago

ofetch brings ergonomic fetch improvements — auto-retry, interceptors, smart parsing — to Node, browser, and edge workers

ofetch is a thin but feature-rich wrapper around the native Fetch API, targeting developers who want automatic JSON parsing, structured error handling, retry logic, interceptors, and TypeScript generics without adopting a heavier HTTP client. It is built and maintained by the UnJS ecosystem (the team behind Nuxt, Nitro, H3), which gives it strong organic adoption across the Vue/Nuxt/Nitro toolchain. Its universal runtime support — Node.js, browsers, and Cloudflare Workers/edge environments — makes it a practical default for isomorphic TypeScript projects.

Origin

Created in December 2020 as part of the UnJS utility collection, ofetch evolved from ohmyfetch and became a first-class dependency of Nuxt 3 and Nitro, giving it a large embedded install base well before independent discovery.

Growth

Growth has been largely pull-based: Nuxt 3's release in late 2022 drove significant adoption since ofetch ships as the default HTTP utility in Nuxt's useFetch composable and Nitro's server toolkit. Independent adoption from developers outside the Nuxt ecosystem appears slower but steady, reflected in a stable star count around 5k with low weekly velocity (3 stars/7 days as of late June 2026), suggesting organic rather than viral growth.

In production

ofetch is a declared dependency of Nuxt 3 and Nitro, both of which have very large production install bases. npm download counts (visible via the badge link) are reported in the millions per month, largely driven by these downstream dependencies. Independent real-world adoption outside the UnJS/Nuxt ecosystem is harder to verify from public sources alone, but transitive install numbers are substantial.

Code analysis
Architecture

Appears to wrap the native Fetch API with a thin middleware/interceptor layer. Likely uses a composable options object pattern with lifecycle hooks (onRequest, onResponse, onRequestError, onResponseError) rather than a class-based client. Relies on the UnJS 'ufo' package for URL/query handling. v2 is currently in alpha on the main branch, with v1 still stable.

Tests

not documented in README

Maintenance

Last push was June 21 2026, four days before evaluation date — actively maintained. The project is under the UnJS organization which has a consistent track record of releasing and maintaining its packages. A v2 alpha branch indicates ongoing architectural investment rather than maintenance-only mode.

Honest verdict

ADOPT IF: you are building within the Nuxt 3, Nitro, or UnJS ecosystem — ofetch is already the idiomatic choice there. Also suitable if you want a lightweight, universal Fetch wrapper with interceptors and retry logic for isomorphic TypeScript projects. AVOID IF: you need a mature, fully stable release (v2 is currently alpha); or your team already has a consistent axios or ky pattern with established tooling. MONITOR IF: you are outside the UnJS ecosystem but evaluating lightweight Fetch wrappers — v2 stabilization may broaden ofetch's standalone appeal.

Independent dimensions

Mainstream potential

5/10

Technical importance

6/10

Adoption evidence

7/10

Risks
  • v2 is currently in alpha on the main branch; the stable API surface may shift before release, introducing friction for early adopters.
  • Adoption outside the Nuxt/Nitro/UnJS ecosystem appears limited; the project may struggle to gain mindshare as a standalone choice against more promoted alternatives like ky or axios.
  • Deep coupling to the UnJS organization means project health depends on that organization's continued commitment; however, this risk is mitigated by UnJS's track record and Nuxt's commercial backing.
  • Low weekly star velocity (3 stars/7 days) suggests the project is not currently in a viral growth phase, which may limit community contributions and third-party plugin development.
  • npm download numbers are heavily influenced by transitive Nuxt/Nitro installs, which may overstate active deliberate adoption by developers making an informed choice.
Prediction

ofetch will remain a stable, well-maintained default for the Nuxt/Nitro/UnJS stack. Mainstream adoption outside that ecosystem is likely to remain modest unless v2 delivers a substantially differentiated feature set.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

TypeScript
99.2%
JavaScript
0.8%

Information

Language
TypeScript
License
MIT
Last updated
2d ago
Created
68mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Similar repos

node-fetch

node-fetch/node-fetch

node-fetch brings the browser's Fetch API to Node.js, allowing developers to...

8.9k JavaScript Dev Tools
better-auth

better-auth/better-fetch

Better Fetch is an advanced fetch wrapper for TypeScript that adds schema...

1k TypeScript Dev Tools
elbywan

elbywan/wretch

Wretch is a lightweight (~1.8KB gzipped) TypeScript wrapper around the Fetch...

5.2k TypeScript Web Dev
vs. alternatives
node-fetch

node-fetch polyfills the Fetch API for older Node.js versions; it does not add ergonomic features (retry, interceptors, auto-parsing). With native fetch in Node 18+, node-fetch's core value proposition has eroded, while ofetch's ergonomic layer remains useful regardless of runtime.

wretch

wretch is the closest philosophical peer — both add a fluent/ergonomic layer on top of native Fetch. wretch uses a chainable builder API; ofetch uses a plain options object. wretch has slightly more stars (5176 vs 5317) and a plugin system; ofetch has deeper UnJS ecosystem integration and arguably simpler defaults.

axios

axios is the dominant HTTP client by raw install volume, with a class-based interceptor model and broad browser/Node support. ofetch is lighter, leverages native Fetch, and avoids axios's XMLHttpRequest legacy. For projects already in the Nuxt/UnJS stack ofetch is a natural fit; for non-Nuxt projects, axios's ecosystem familiarity may outweigh ofetch's ergonomic gains.

ky

ky is another Fetch-based ergonomic wrapper from Sindre Sorhus, with similar retry and hook features. ky is more actively promoted as a standalone tool and has a larger independent following; ofetch differs mainly in its tighter UnJS integration and server-side emphasis via Nitro.

undici (Node built-in fetch)

Node.js 18+ ships native fetch via undici. For simple use cases this eliminates the need for any wrapper. ofetch's added value (retry, interceptors, smart parsing, edge-compat) remains relevant for anything beyond basic GET requests.