tRPCttRPC
Powered by
defaultgnomeD
tRPC•2y ago•
29 replies
defaultgnome

Forward NextJs Request to TRPC Server

Hey everyone! I need some help with my project setup. Here's my current situation:

My Setup:

* I have a NextJS 14 project (which is both client-side and server-side)
* I also have a separate ExpressJS tRPC server

What I Want to Achieve:
I want both the client-side and server-side of my NextJS app to communicate with the tRPC server. However, I have a specific requirement for the client-side:

1. The client-side of NextJS should first talk to a NextJS route handler
2. Then, this route handler should make the call to the tRPC server

My Issue:

I'm not sure how to set this up correctly. I need help figuring out:

1. How to implement the NextJS route handler to act as a middleman
2. Best practices for this kind of setup?

Has anyone done something similar or have any ideas on how to approach this? Any tips, code snippets, or resources would be greatly appreciated!
image.png
tRPCJoin
Move Fast & Break Nothing. End-to-end typesafe APIs made easy.
5,015Members
Resources
Recent Announcements

Similar Threads

Was this page helpful?

Similar Threads

Express tRPC NextJS
MugetsuMMugetsu / ❓-help
3y ago
NextJS + TRPC + NX
CaptainCCaptain / ❓-help
4y ago
Using trpc with fastify server and nextjs client
ZionZZion / ❓-help
3y ago
tRPC requests on client vs server for NextJs
noahNnoah / ❓-help
3y ago