Is a Monorepo the Best Choice for My Web, Mobile, and API Project?

0
0
Asked By CuriousCoder42 On

Hey everyone! I'm diving into a new project and trying to nail down the best repository structure. Here's the stack I have in mind:
- Web app with React and TanStack Router
- Mobile app using React Native, sharing as much logic as possible with the web app
- Backend API built with Fastify

Both the web and mobile apps will utilize the same API, and I also want to reuse some authentication logic with BetterAuth, along with shared API request functions.

So, I'm wondering:
1. Should I go with a monorepo for both the web and mobile apps, or would it be better to keep them in separate repositories?
2. Should I include the API (Fastify backend) in the same monorepo as well, or should that be kept separate?
3. Are there any potential downsides or edge cases to consider when sharing logic between React and React Native, particularly around API clients or authentication modules?

I'd really appreciate hearing about how others have tackled this kind of setup. Thanks in advance!

6 Answers

Answered By DevNinja88 On

I don't see a problem with going monorepo! I've done several microservice projects that I kept in the same monorepo, which made things easier. One useful approach I've taken is to put shared functionality in a separate folder and publish it as an npm package for the other parts to use as dependencies.

Answered By SharedLogicGuru On

Yeah, you should stick with a monorepo. Your plan is tailored for it since you’re already sharing code. Everything from types to auth logic can be centralized, making refactoring and history tracing much easier. If you ever need to scale or secure things separately, splitting off the API later is totally doable. Just watch out for any shared UI code that might not jive well between React and React Native.

Answered By TechieTraveler On

Honestly, monorepos are generally easier to manage if they're well-organized. If you set it up right, it can streamline a lot of processes.

Answered By CodeConnoisseur On

It's actually less hassle to break apart a monorepo than to merge separate repos later on. Plus, your setup is practically built for it.

Answered By DevDude003 On

I'd say monorepo all the way. Otherwise, you’d need to publish another repo privately to import into your mobile and web apps which can add complexity.

Answered By CodeWizard99 On

Definitely go for a monorepo! Just organize your directories at the root for frontend, backend, and mobile. It simplifies everything.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.