docs: clarify when to install undici vs using Node's built-in fetch#4868
Merged
mcollina merged 2 commits intonodejs:mainfrom Mar 8, 2026
Merged
docs: clarify when to install undici vs using Node's built-in fetch#4868mcollina merged 2 commits intonodejs:mainfrom
mcollina merged 2 commits 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
| | ||
| ### 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 | |
- Add cross-platform interoperability (browsers + runtimes) as a reason to use the built-in fetch API - Update proxy support section to reflect that EnvHttpProxyAgent is now supported by native fetch in Node.js v22.21.0+ and v24.0.0+ via --use-env-proxy, while noting undici's ProxyAgent still offers programmatic dispatcher-based control - Add Node.js v24 row to the version compatibility table Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
metcoder95 approved these changes Mar 8, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@ ## main #4868 +/- ## ========================================== - Coverage 93.14% 93.02% -0.12% ========================================== Files 109 112 +3 Lines 34254 35176 +922 ========================================== + Hits 31905 32723 +818 - Misses 2349 2453 +104 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merged
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