Add custom fetch injection to FetchHttpClient for Next.js caching
Automated Changes by SimulateDev
Setup
Task
Add custom fetch injection capability to FetchHttpClient to enable Next.js caching support while maintaining backward compatibility.
Coding agents used
- cursor with claude-4-sonnet as Planner
- cursor with claude-4-sonnet as Coder
- cursor with claude-4-sonnet as Tester
Execution time
⏱️ 13m 32.2s
Summary
This PR addresses issue #4922 by adding the ability to inject a custom fetch implementation into the FetchHttpClient. The new layerWithFetch function allows developers to provide their own fetch implementation, enabling the use of Next.js's patched fetch and its caching capabilities. The changes maintain full backward compatibility while providing a clean API for custom fetch injection. Implementation was completed using Cursor IDE with Claude-4-Sonnet across planning, coding, and testing phases.
What changed?
- Added
layerWithFetchfunction topackages/platform/src/FetchHttpClient.ts - Created internal
layerWithFetchexport inpackages/platform/src/internal/fetchHttpClient.ts - Updated documentation and usage examples for custom fetch injection
- Maintained backward compatibility with existing
layerexport - Enhanced support for Next.js caching through custom fetch implementation
Review Instructions
Please carefully review all changes before merging. While AI agents are powerful, human oversight is always recommended.
Generated by SimulateDev, the AI coding agents collaboration platform.
⚠️ No Changeset found
Latest commit: 223058b4b76f88047d6384b58b86dfab9a0c83b1
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
You can already inject a custom fetch function: https://github.com/Effect-TS/effect/tree/main/packages/platform#injecting-fetch