Does Start & Router remove the need for something like TRPC?
I am trying to think through what would still be the use case of using TRPC with react start.
What is everyone's opinion on this?
16 Replies
automatic-azure•8mo ago
The only reason I'm using tRPC in my start application is for other clients. Using
createServerFn
I can co-locate my server fns next to my queryOptions
I've found tRPC to be a little painful to use and switching to server functions made it a lot easier
Eventually I hope that tanstack start will support openapi schemas for it's routes and then that'll remove the need for tRPCrare-sapphire•8mo ago
What do you mean?
automatic-azure•8mo ago
Currently with tRPC I can export a schema in TypeScript types that I can use in other clients. I could do the same using OpenAPI and generate a typescript client library. It's a very low priority feature as I'm aware that openapi integration is still experimental in Nitro
fascinating-indigoOP•8mo ago
what other types of clients are you building? I am thinking through some of my structure for project that has a react and react native/expo app, I almost was reaching for trpc
that is why I randomly posted this question
automatic-azure•8mo ago
I have used tRPC for an Expo application and it's a really good fit, that's probably the most valid reason. At the time (about a year ago) I combined it with
@tanstack/query
and AsyncLocalStorage
The current application has a discord bot attached to it that utilises Tanstack Start's API Routes + tRPC. Because the Discord bot has a persistent connection it can't be part of my start application and needs to be ran seperatelyfascinating-indigoOP•8mo ago
how are you sharing functions between your trpc routes and api routes? or do you share much between them
automatic-azure•8mo ago
I share quite a bit, I've made seperate
x.services.ts
files which export the server functions in their simplest form.
https://github.com/Team3132/AttendanceSystem/blob/main/packages/frontend/app/server/services/events.service.ts
I don't have many API routes outside of tRPC but I'm looking at adding a couple using webhooks triggered by cron.
This is a bit of a sandbox project so there's probably a better way to achieve a couple things that I'm doingfascinating-indigoOP•8mo ago
I always feel like there has to be a better way in my projects
I think that is where I am on this project, I have just a nextjs project, expo app and a legacy .net api, I am thinking of replacing the .net api (it is a big chunk to replace though) and working on getting it to tanstack router
automatic-azure•8mo ago
The only annoying thing about developing with start and a mobile app is that there's not really a good way to do versioning like in dotnet
Because mobile apps don't have instant updates
fascinating-indigoOP•8mo ago
eas is the way to go with expo
automatic-azure•8mo ago
Ah, yep. The last project I was on didn't use EAS
that would probably streamline things a bit
fascinating-indigoOP•8mo ago
And some of the things they are doing with their universal components/server components is very interesting concepts
automatic-azure•8mo ago
Yeah, Expo is doing a great job with react on mobile
I would say they're a NextJS equivalent for mobile applications
fascinating-indigoOP•8mo ago
But with that to come full circle to my original thoughts in this thread. Is the only real reason to use TRPC when building an product that may have a RN and React app?
I feel like TRPC is great in some ways and a lot of work in others
automatic-azure•8mo ago
Yeah, or other services that can't run on edge functions
fascinating-indigoOP•8mo ago
yeah I have to run things in a specific environment to access my SQL Azure