# Extension points — sindresorhus/got

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

# Extension points — sindresorhus/got

Scanned commit e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4 (2026-09-20). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Extension is primarily instance composition and callback-based customization. Handler middleware wraps the request interface, while lifecycle hooks operate at specific normalization and transport stages. Request functions, connection factories, agents, cookie jars, and cache adapters substitute infrastructure without replacing the public client. Pagination and JSON callbacks customize data interpretation and follow-up behavior.
- got.extend(...instancesOrOptions) merges option histories, concatenates handlers, carries mutableDefaults settings, and calls create() to produce a new instance. — [source/create.ts#L154-L181](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L154-L181)
- HandlerFunction receives Options and next(options); iterateHandlers dispatches them in order and preserves Promise helper descriptors on wrapped results. Stream handlers must return synchronously according to the instance documentation. — [source/types.ts#L42-L48](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/types.ts#L42-L48) [source/create.ts#L120-L144](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L120-L144) [documentation/10-instances.md#L70-L85](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/10-instances.md#L70-L85)
- Hook registration accepts only recognized hook events and function arrays; merging appends hooks, and init hooks can consume custom raw options into context before unknown-option validation. — [source/core/options.ts#L2447-L2473](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2447-L2473) [source/core/options.ts#L1712-L1728](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1712-L1728) [documentation/lets-make-a-plugin.md#L87-L111](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/lets-make-a-plugin.md#L87-L111)
- The request option can supply a custom request/response synchronously or asynchronously; undefined results fall back to the built-in transport. A beforeRequest hook can short-circuit later hooks by returning a request or response. — [source/core/options.ts#L3606-L3635](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3606-L3635) [source/core/options.ts#L3775-L3785](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3775-L3785) [source/core/index.ts#L2516-L2531](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2516-L2531)
- Transport customization uses protocol-specific agents, createConnection, dnsLookup/dnsCache, and h2session; stable wrapped DNS lookup identity is deliberately maintained for HTTP/2 session reuse. — [source/core/options.ts#L1195-L1206](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1195-L1206) [source/core/options.ts#L3578-L3593](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L3578-L3593) [source/core/utils/http2-client.ts#L1686-L1699](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/utils/http2-client.ts#L1686-L1699)
- Cache storage accepts Map-like adapters, with QuickLRU TTL translation; beforeCache hooks synchronously mutate cache metadata or return false to prevent storage, and Promise returns are rejected. — [documentation/cache.md#L27-L42](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/documentation/cache.md#L27-L42) [source/core/options.ts#L1209-L1235](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1209-L1235) [source/core/index.ts#L2206-L2231](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L2206-L2231)
- Pagination customization replaces transform, filter, shouldContinue, and paginate callbacks; paginate can stop with false or supply updated options, and returned pagination settings affect subsequent iterations. — [source/create.ts#L198-L204](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L198-L204) [source/create.ts#L235-L255](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L235-L255) [source/create.ts#L263-L275](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L263-L275) [source/create.ts#L339-L342](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/create.ts#L339-L342)
- parseJson/stringifyJson replace JSON codecs; cookieJar implements getCookieString/setCookie, with legacy callback jars promisified; diagnostics subscribers consume typed lifecycle messages through Node channels. — [source/core/options.ts#L1297-L1298](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L1297-L1298) [source/core/response.ts#L193-L199](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/response.ts#L193-L199) [source/core/index.ts#L1005-L1008](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/index.ts#L1005-L1008) [source/core/options.ts#L2195-L2208](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/options.ts#L2195-L2208) [source/core/diagnostics-channel.ts#L6-L14](https://github.com/sindresorhus/got/blob/e1d87d2ced01d5b7d855a7dc8b091bf7b014a1e4/source/core/diagnostics-channel.ts#L6-L14)

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)
