How to incrementally adopt Edge functions with multiple TRPC backends
While researching edge functions for improving performance on my company's app lore.xyz, I found a way to get the client type safety of TRPC with the performance improvements of edge functions all bundled into a familiar trpc client API. But I needed...
stewartcodes.hashnode.dev3 min read
Thank you so much for sharing this brilliant solution! I was struggling to get React Query integration working with tRPC edge runtime, and your dynamic routing approach with custom links solved it perfectly.
The idea of using a custom link function to route api.edge.* calls to the edge runtime while keeping api.* calls on the regular Node.js runtime is genius. This gives us the best of both worlds - edge runtime performance with full tRPC React Query integration and type safety.
I implemented this in my Next.js project and it works flawlessly. Now I can use api.edge.*.useQuery() with all the React Query features while actually running in edge runtime. The dynamic routing is so elegant!
Your blog post saved me hours of work. Thank you for taking the time to document and share this solution! 🙏