What I Actually Share in a React Monorepo
Servora has several frontends in one repo. The useful shared code turned out to be much smaller than I first expected.
Key takeaways
Share contracts when applications must agree.
Keep role-specific workflows close to the app that owns them.
Do not create a shared package just because two files currently look similar.
What went wrong first
The temptation was to share too much.
Servora has an admin/POS app, kitchen display, waiter app, customer app, public website and API. Because they live in the same monorepo, it is very easy to look at two similar files and move them into a shared package immediately.
I stopped doing that after a few cases where a “shared” abstraction made a small change harder. The kitchen and waiter apps may both work with orders, but the screen flow, permissions and urgency are different. Sharing the domain does not mean sharing the workflow.
- Share things that genuinely need to stay identical.
- Leave product flow inside the product surface that owns it.
- Accept a little duplication until the common shape is obvious.
One important boundary
Shared frontend code still does not make the frontend authoritative.
Pricing and availability are good examples. Every client can use shared types and helpers so the UI stays consistent, but the API still validates the final price, availability and permission state.
That separation matters because frontend code can be stale, bypassed or simply wrong. Shared contracts improve consistency; server authority protects the business rule.
The rule I use now
Share disagreement-sensitive code. Be conservative with everything else.
If two apps disagree on an order-status type, request schema or realtime event, that is dangerous and should be centralized. If they render different order flows for different users, that difference is usually intentional.
This is a simpler rule than chasing DRY everywhere, and it has made the repo easier to change.
- Types and validation: usually shared.
- API and realtime contracts: usually shared.
- Design primitives: shared after their semantics settle.
- Pages and role-specific workflows: usually local.
Share contracts when applications must agree.