docs: document createFetch custom fetch option by poetryofcode · Pull Request #603 · unjs/ofetch · GitHub
Skip to content

docs: document createFetch custom fetch option#603

Open
poetryofcode wants to merge 1 commit into
unjs:mainfrom
poetryofcode:docs/document-createFetch-custom-fetch-option
Open

docs: document createFetch custom fetch option#603
poetryofcode wants to merge 1 commit into
unjs:mainfrom
poetryofcode:docs/document-createFetch-custom-fetch-option

Conversation

@poetryofcode

@poetryofcode poetryofcode commented Jun 29, 2026

Copy link
Copy Markdown

Summary

Fixes #533

The createFetch function accepts a fetch option in CreateFetchOptions that lets you provide a custom fetch implementation. This is useful for Node.js-compatible fetch (e.g. undici), service worker fetch, or test mocks — but it was completely undocumented in the README.

Changes

  • README.md: Added a new "🔧 Using a custom fetch implementation" section after "Create fetch with default options", showing how to use createFetch({ fetch: customImpl }) with a basic example and a practical undici example.

Test plan

  • README renders correctly on GitHub and npmjs.com

Summary by CodeRabbit

  • Documentation
    • Added guidance for using a custom fetch implementation when creating an ofetch instance.
    • Included examples for passing a custom fetch function and using undici’s fetch in Node.js.
    • Expanded the setup docs with this new option alongside the default configuration example.

The `createFetch` function accepts a `fetch` option in `CreateFetchOptions`
that allows passing a custom fetch implementation. This is useful for
providing a Node.js-compatible fetch (e.g. undici), a service worker's
fetch, or a test mock — but was not documented in the README.

Closes unjs#533

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ability to pass in custom fetch fn is not documented

1 participant