Seeking Advice for a T3 Stack Application: Separating tRPC from NextJS

I am currently planning to develop a web application using a T3 stack that includes tRPC, NextJS, and Prisma (or Drizzle). My specific focus is to run tRPC as a standalone server, separate from NextJS. My primary request is to find any starter templates or resources that align with this architecture. Has anyone here worked on a similar setup, or can anyone point me towards resources or templates that would facilitate this kind of structure? Additionally, I'm curious about the compatibility of Next-Auth in this separated architecture. Is it feasible to integrate Next-Auth effectively when tRPC is running on its own server? Any insights, experiences, or advice on either of these points would be immensely helpful. I'm particularly interested in challenges or lessons learned from setting up a similar architecture, especially regarding the integration of Next-Auth. Thank you in advance for your help and insights!
7 Replies
vibbin
vibbin14mo ago
Sounds like you're looking for something like t3-turbo? https://github.com/t3-oss/create-t3-turbo
GitHub
GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo usin...
Clean and simple starter repo using the T3 Stack along with Expo React Native - GitHub - t3-oss/create-t3-turbo: Clean and simple starter repo using the T3 Stack along with Expo React Native
cje
cje14mo ago
t3-turbo still uses the next.js backend what is your reason to not want to use next? the answer to this will determine what makes the most sense basically it's possible - tRPC runs just about anywhere, and I know that next-auth runs fine in Express, so I'd assume you can also get it working in other node environments
DraganovicDr
DraganovicDrOP14mo ago
Yes I want the backend api to be separate cause it's going to be used by many other applications not only the NextJS app Reading a bit about tRPC I found that it doesn't produce normal Rest API endpoints so now I'm thinking about using Hono instead, but I don't know if Hono plays well with ReactQuery or if they have something similar. But I still don't understand how ReactNative can access the API, as far as I know NextJS doesn't expose it's API to the public
BillyBob
BillyBob12mo ago
Hey @DraganovicDr What did you decide in the end?
Jonathan.Alphonso
For anyone looking for solutions here. You may want to try exposing your trpc procedures as rest endpoints. https://create.t3.gg/en/usage/trpc#exposing-every-procedure-as-a-rest-endpoint
Create T3 App
tRPC 🚀 Create T3 App
The best way to start a full-stack, typesafe Next.js app.
Martoxdlol
Martoxdlol12mo ago
https://trpc.io/docs/server/adapters tRPC can be use with different adapters. Choose one and follow the documentation. Is not that hard to setup trpc yourself.
Adapters | tRPC
tRPC is not a server on its own, and must therefore be served using other hosts, such as a simple Node.js HTTP Server, Express, or even Next.js. Most tRPC features are the same no matter which backend you choose. Adapters act as the glue between the host system and your tRPC API.
Josh Grant
Josh Grant12mo ago
I see this thread is old, but incase someone else is interested in this less common approach. I am very far down the road with this stack and regret a few choices: prisma tRPC Clerk NextJS turborepo AWS ECS AWS RDS Vercel is not HIPAA Compliant so that was not an option. Amplify does not allow me to run the server in a VPC so that was not an option. Let me know if you want to talk sometime, you might save some time and avoid some of the battles I have had.
Want results from more Discord servers?
Add your server