You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: support using fetchEventSource for subscriptions #6950
Would be awesome to be able to utilize this out of the box in tRPC.
Describe alternate solutions
We use tRPC with header auth, but now to use subscriptions we have to either expose our tokens via a get param or implement a subscription specific token process.
Additional information
No response
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
Support dynamic header injection for JWT/Bearer tokens
Enable cookie-based authentication for cross-origin scenarios
Implement retry logic with token refresh capability
Migration Path
Deprecate EventSource-based implementation with clear migration guide
Provide feature parity testing suite
Add comprehensive TypeScript types for new subscription client
Key Benefits
Solves header-based auth limitations
Enables cross-origin cookie support
Maintains type safety throughout subscription lifecycle
Provides better error handling and retry mechanisms
Would be happy to contribute to the implementation if this approach aligns with the team's vision. The complexity involves deep integration with tRPC's link system and subscription resolver pipeline.
@ravikant-diwakar if you gonna have ai write for you, tell it to be concise. I've already said that I accept prs and the constraints in one sentence. If you have actual questions once/if you start work on it, please let me know
Activity
KATT commentedon Sep 18, 2025
Yeah, I want to get rid of EventSource too. I agree with everything
KATT commentedon Sep 18, 2025
I'd do a new httpLink, make sure it works with
resolveResponse, and deprecate the old one (ensuring that there's functionality pairity)ravikant-diwakar commentedon Sep 19, 2025
Technical Implementation Approach
This is an excellent enhancement for tRPC's subscription architecture. Here's my proposed technical solution:
Core Implementation Strategy
New HTTP Link Architecture
httpFetchEventSourceLinkalongside existinghttpSubscriptionLinkresolveResponsepipelineTypeScript Interface Design
Authentication Flow Enhancement
Migration Path
EventSource-based implementation with clear migration guideKey Benefits
Would be happy to contribute to the implementation if this approach aligns with the team's vision. The complexity involves deep integration with tRPC's link system and subscription resolver pipeline.
KATT commentedon Sep 19, 2025
@ravikant-diwakar if you gonna have ai write for you, tell it to be concise. I've already said that I accept prs and the constraints in one sentence. If you have actual questions once/if you start work on it, please let me know
Kkartik14 commentedon Jan 11, 2026
Hey @KATT we can use fetch and manual SSE parsing to update headers, If it's still open, can i work on it?
evolvomind commentedon Feb 19, 2026
Hi, @KATT
May I work on this issue?
nylakaidan-ship-it commentedon Mar 29, 2026
KATT commentedon Nov 2, 2026
🤖 In v12,
httpLinkreads subscriptions as SSE overfetchinstead ofEventSource, so the link'sheadersandinitoptions (e.g.credentialsfor cross-origin cookies) apply to subscriptions just like queries and mutations. https://v12.trpc.io/v12/docs/client/links/http#subscriptions. v12 isn't released yet and there's no ETA.