Struggling to Choose a Type-Safe Backend for a Podcast Streaming Service Without a Monorepo
I’m building a podcast streaming service using Next.js for the web and a React Native app for mobile. I’m not sure what to do about the backend. I really want to use tRPC for both, but tRPC feels a bit complex since I don’t want to use a monorepo (it’s an extra headache). I want to keep them in separate repositories.
Here’s my current idea:
- Use raw Next.js API routes (without tRPC) and consume that API in the React Native app.
- Alternatively, use Hono.js as a serverless framework, host it on Cloudflare Workers, and consume it in both Next.js and React Native.
The problem is that neither approach will be type-safe, and I think that will cause more headaches in the long run. You might suggest using GraphQL with a type generation tool, but I’ve tried writing GraphQL backends before and found the experience horrible.
What should I do? I’d love to hear your thoughts.
10 Replies
also I want to pick good architecture from beginning because when it'll scale I dont want to try changing some stuff in backend
can't you export the hono type as a dep?
RPC - Hono
Web framework built on Web Standards for Cloudflare Workers, Fastly Compute, Deno, Bun, Vercel, Node.js, and others. Fast, but not only fast.
or "publish" the whole app as well
or a git submodule
when you make changes to the api repo, just pull it in the specific other repo
wow I didnt know about that
is there tool for type generation such as graphql-cli? i'm building rn for trpc, made it as well to use that for my use case but i was getting CORS errors in another project when i was making request
You should ignore the export type part
Use the submodule and avoid a whole lot of issues
okay that looks fine
It’s not the standard these days but should work in your case
You just need to check how to deploy stuff with submodules
But regardless, it’s an option
so in my use case graphql is the best option i guess right?
its standard
Do you want to use code generation?
You can use OpenAPI + openapi generator