# Extension points — unjs/ofetch

> Canonical page: https://codevetter.com/unpack/ofetch/extension-points

# Extension points — unjs/ofetch

Scanned commit 1dbc37fd1ceab832fc7c90cad81b1091c95ba563 (2026-07-08). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Extension primarily happens through factories, typed options, and lifecycle hooks. Transport injection permits alternative fetch implementations without changing the request pipeline. Parsers and response mappings offer decoding customization, while dispatchers expose runtime-specific networking. Source-level helper tables define the narrower places where core behavior can be extended.
- CreateFetchOptions.fetch injects a fetch-compatible transport into createFetch, allowing tests or adapters to replace network execution. — [src/types.ts#L80-L83](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L80-L83) [src/fetch.ts#L36-L37](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L36-L37) [src/fetch.ts#L180-L184](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L180-L184)
- $fetch.create accepts shared defaults and custom global options, preserving inherited globals while new defaultOptions have final shallow precedence. — [src/types.ts#L15-L15](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L15-L15) [src/fetch.ts#L268-L277](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L268-L277)
- FetchHooks defines four typed lifecycle interfaces; callHooks awaits array members sequentially using the same mutable context. — [src/types.ts#L94-L117](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L94-L117) [src/utils.ts#L140-L152](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L140-L152)
- parseResponse replaces JSON.parse after text consumption and takes precedence over responseType by selecting the JSON branch. — [src/types.ts#L38-L40](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L38-L40) [src/fetch.ts#L209-L220](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L209-L220)
- ResponseMap and MappedResponseType centralize compile-time result mapping; adding response types requires coordinating these types with runtime decoding. — [src/types.ts#L123-L135](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L123-L135) [src/fetch.ts#L215-L230](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L215-L230)
- retryStatusCodes and retryDelay permit application-specific retry selection and contextual delay calculation without modifying the built-in status set. — [src/types.ts#L64-L70](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L64-L70) [src/fetch.ts#L57-L69](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/fetch.ts#L57-L69)
- FetchOptions can be augmented through TypeScript module declaration merging, with custom fields available to shared onRequest hooks. — [README.md#L356-L383](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/README.md#L356-L383) [src/types.ts#L22-L24](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L22-L24)
- dispatcher and legacy agent options expose transport configuration; core payload-method and content-type sets are localized in utils.ts for source-level extensions. — [src/types.ts#L49-L59](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/types.ts#L49-L59) [src/utils.ts#L10-L14](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L10-L14) [src/utils.ts#L45-L82](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/src/utils.ts#L45-L82) [examples/proxy.mjs#L3-L16](https://github.com/unjs/ofetch/blob/1dbc37fd1ceab832fc7c90cad81b1091c95ba563/examples/proxy.mjs#L3-L16)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
