Skip to content
Kuldip Kumar SahSenior Frontend Engineer
All articles
Architecture8 min read

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.

ReactTypeScriptMonorepoArchitectureServora

Key takeaways

01

Share contracts when applications must agree.

02

Keep role-specific workflows close to the app that owns them.

03

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.
Admin / POS
Kitchen
Customer
Types · Validation · API Client · Realtime · UI
Server authority
share contracts → keep workflows local

What survived

The boring packages became the most useful ones.

The packages that have held up best are types, validation, the API client, realtime primitives, configuration and low-level UI pieces. They are useful because disagreement in those areas creates real bugs.

I am much more careful with shared feature logic now. If a waiter workflow changes independently from the POS workflow, I would rather keep that code local than force both apps through one abstraction with a pile of conditionals.

I now ask “what breaks if these apps disagree?” before I ask “can this code be shared?”
Working principle

Share contracts when applications must agree.

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.

Selection
Preview
Explain
Authorize
Recalculate
Commit
client intent → API decision → realtime committed state

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.
Working principle

Share contracts when applications must agree.