docs: clarify when to install undici vs using Node's built-in fetch#4868
Open
travisbreaks wants to merge 1 commit intonodejs:mainfrom
Open
docs: clarify when to install undici vs using Node's built-in fetch#4868travisbreaks wants to merge 1 commit intonodejs:mainfrom
travisbreaks wants to merge 1 commit intonodejs:mainfrom
Conversation
Adds a best-practices doc page explaining when to install undici from npm versus relying on Node.js's built-in fetch. Covers advanced APIs, connection pooling, proxy support, mocking, interceptors, and version compatibility. Also adds a sidebar link so the guide is discoverable in the docs site. Closes nodejs#4066 Co-authored-by: Egger <egger@horny-toad.com>
metcoder95
reviewed
Mar 6, 2026
Member
metcoder95
left a comment
There was a problem hiding this comment.
lgtm, just smaller details
| If all of the following are true, you can rely on the built-in globals and skip | ||
| adding undici to your dependencies: | ||
|
|
||
| - You only need the standard Fetch API (`fetch`, `Request`, `Response`, |
Member
There was a problem hiding this comment.
I'd suggest to add the desire of having cross-platform interoperability (browsers + runtimes)
|
|
||
| ### Proxy support | ||
|
|
||
| `ProxyAgent` and `EnvHttpProxyAgent` handle HTTP(S) proxying, which is not |
Member
There was a problem hiding this comment.
EnvHttpProxyAgent is currently supported by native fetch.
| |---|---|---| | ||
| | v18.x | ~5.x | `fetch` is experimental (behind `--experimental-fetch` in early v18) | | ||
| | v20.x | ~6.x | `fetch` is stable | | ||
| | v22.x | ~6.x / ~7.x | `fetch` is stable | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This relates to...
#4066
Changes
While PR #4245 added an "Undici vs. Fetch" section to the README, this PR adds a dedicated best-practices guide page within the docsify documentation site, making the information discoverable from the docs sidebar.
The new guide at
docs/docs/best-practices/undici-vs-builtin-fetch.mdcovers:fetch,Request,Response,Headers, andFormDataglobalsrequest,stream,pipeline), connection pooling (Client,Pool,BalancedPool), proxy support (ProxyAgent), testing/mocking (MockAgent), interceptors, or getting a newer version than what Node.js bundlesAlso adds the guide to the docsify sidebar under "Best Practices" (first entry, as the issue requested it be "near the top").
Status
Co-authored-by: Egger egger@horny-toad.com