Moving tRPC out of Next #1008
Replies: 2 comments 3 replies
-
Your Next.JS endpoints are usually and should usually be where you host your server. You can adapt the api package to export what you need to use on your new backend app. be it express or whatever it is. The main reason to have a separate api package is so that you can include that as a dev dependency in a frontend app and this way have access to the types tRPC will provide for your app router. Why are you skeptical of using the Next.JS backend? Is it just so you can fully separate frontend from backend? |
Beta Was this translation helpful? Give feedback.
-
You could expose the trpc api on the auth-proxy server using Nitro if you want |
Beta Was this translation helpful? Give feedback.
-
Hey everyone! Big supporter of the amazing work @juliusmarminge has done here.
I began with this repo a couple months ago and as I've started ...productionizing things for my use-case it's come to my attention that there are a few benefits for separating out the api from running on next, principally for independent scaling + deployment + development.
However, I still really like the code completion / ease of use of that tRPC offers and would like to keep that DX. Ideally, I can wrap more or less the
trpc/[trpc]/route.ts
in some express/koa/whatever the newest framework is server, and start routing my requests there both fromexpo
and the nextjs frontend, but keep the DX/typesafety currently offered.Does anyone have any thoughts or experience on/with this? To admit my bias, I come as a former backend dev and still don't feel really comfortable with using Next endpoints for all my use cases, especially because my primary application is a mobile one and our webapp is very secondary.
Beta Was this translation helpful? Give feedback.
All reactions