Why Manual fetch() + Suspense is Hard
You'll learn: Why directly combining fetch() with Suspense requires complex infrastructure you probably shouldn't build yourself.
The Alluring Simplicity... That Isn't
At first glance, Suspense seems simple: throw a promise during render, React shows a fallback, resume when ready. You might think: "I'll just fetch(), throw the promise, and I'm done!"
Unfortunately, making this work in production requires solving three hard problems simultaneously.
The Three Hidden Challenges
1. Cache Coordination
Every time your component re-renders (parent state change, prop update), it renders again. If you naively call fetch() each time, you'll fire duplicate network requests. You need a cache that:
- Stores in-flight promises by key
- Reuses the same promise if already fetching
- Stores resolved data to prevent re-fetching
2. Deduplication
If two components request the same data simultaneously (both suspended), you must ensure only one network request goes out. Without this, you'll hammer your API. This requires global promise tracking—complex to build correctly.
3. Error Boundaries Integration
When a fetch fails, you throw an error during render. Error boundaries catch it—but now your component is stuck. You need mechanisms to:
- Distinguish network errors from render errors
- Allow retry without unmounting the boundary
- Clear failed promises from cache
Why Libraries Exist
TanStack Query, Relay, and framework loaders handle all this for you. They've spent years solving race conditions, memory leaks, and edge cases. Building your own "Suspense-ready fetch" means reinventing thousands of lines of battle-tested code.
Key Takeaway: Manual fetch() + Suspense requires building a sophisticated caching layer with deduplication and error recovery—complexity that specialized libraries already solve reliably.