ofetch is an HTTP client built on the native fetch API that adds automatic JSON serialization, request/response interceptors, configurable retry, and timeout handling. It provides descriptive error objects for non-OK responses and automatically parses response bodies based on their content type.
The client supports creating pre-configured instances with preset base URLs, headers, and default options, enabling consistent configuration across a project. It offers full TypeScript type inference for response data and request payloads, and allows extending request options with custom properties while preserving type safety. Additional capabilities include hooking into the request lifecycle via async interceptors, routing requests through proxy servers using standard environment variables, and consuming Server-Sent Events streams in real time.
The library also provides flexible error handling with parsed response bodies, the ability to access raw Response objects, and support for request body serialization including binary data. ofetch is available as a TypeScript package and can be installed via common JavaScript package managers.