One repo, every app

Web, mobile, API and shared packages in one Turborepo monorepo. How I run it, why one repo beats a folder of them, and when you shouldn't bother.

Prabir Singh, profile photoPrabir Singh·
·Updated ·10 min read
Editorial illustration: Three distinct model buildings connect to the same visible foundation and shared supply channels.
In this article
  1. 01What actually lives in the tree
  2. 02The shared types package is the whole point
  3. 03Where Turborepo earns its keep
  4. 04What this looks like in a real build
  5. 05Be honest, you might not need this yet
  6. 06Prove that the cache knows what changed
  7. 07Frequently asked questions
  8. 08One source of truth, defended by the compiler

A founder once showed me three repos on a call. Web, mobile, backend. Each with its own copy of the same User type, each slightly out of date, each a small lie waiting to break in production. Nobody wrote it that way on purpose. It grew there, one Friday deploy at a time, the way weeds grow through a footpath.

I run the opposite. One repo. Everything that ships the product lives in the same tree, and the parts that matter, the types and the logic, get written once.

Here's the thing that took me a while to see. A monorepo isn't really about where your files live. It's about where a change lives. In three repos, one idea gets smeared across three pull requests. In one repo, it fits in one.

What actually lives in the tree

The layout is boring on purpose. Boring is what you want at 2am when something is on fire and you need to find it fast.

PathWhat it isBuilt with
apps/webThe marketing site and dashboardNext.js or TanStack Start
apps/mobileiOS and Android from one codebaseExpo
apps/apiThe server the other two talk toHono
packages/typesShared types and validationTypeScript, Zod
packages/dbSchema and queriesDrizzle, Postgres
packages/uiShared components and tokensReact, Tailwind
packages/configESLint, TS, Tailwind presetsplain config

The web framework choice has its own article, Next.js vs TanStack Start, and the API side is why I reach for Hono over Express. This piece is about the tree that holds them.

The one rule that keeps it clean

Apps consume. Packages provide. The web app never reaches into the mobile app, and neither of them talks to Postgres directly. They go through packages/db.

Think of it like gravity. Dependencies fall downward, never up. Apps depend on packages, packages depend on lower packages, and nothing climbs back. In the food delivery platform I took it one step further: each package exposes one public door, and reaching past it into another domain's internals is a build failure, not a code-review argument. Arguments get lost. Build failures don't.

The shared types package is the whole point

Everything else is nice. This is the reason.

One package owns the shapes the product runs on. The API imports it to validate requests. The web client imports it to type its fetch calls. The Expo app imports the exact same file. There is no fourth copy drifting off in a corner.

// packages/types/src/user.ts
import { z } from "zod";
 
export const userSchema = z.object({
  id: z.uuid(),
  email: z.email(),
  displayName: z.string().min(1),
  plan: z.enum(["free", "pro"]),
});
 
export type User = z.infer<typeof userSchema>;

Now watch what happens when the server changes. I rename plan to tier, or add a required field. The moment I save, TypeScript lights up red in apps/web and apps/api and apps/mobile at the same time. Not in staging. Not from a bug report three weeks later, filed by someone's confused user. On my screen, before I've opened a browser.

That's the feeling I chase. The compiler doing the nagging so I don't have to remember. It's the same reason I'm stubborn about the language in the first place, which I ranted about properly in TypeScript or nothing.

Why one repo beats three

Three repos means three deploys to change one field. It means a backend pull request that can't be verified until the frontend one lands, which can't be verified until someone bumps a package version, which nobody wants to do on a Friday. The change is small. The ceremony is enormous.

One repo collapses that. The type change, the API handler, the web form, and the mobile screen move together in a single pull request. You read the whole change in one diff. You ship it in one go.

Side by side

Several reposOne monorepo
Changing a shared fieldOne PR per repo, plus a version bumpOne PR
Where types liveCopied, and driftingOne package, imported everywhere
When a mismatch shows upRuntime, often in productionCompile time, on your screen
Build speed without toolingEach repo cold-starts its own pipelineSlow, until you add a task runner
Ownership modelFits teams that never share codeFits teams that share code and cadence

Notice the fourth row. A monorepo isn't free. It needs a task runner, which is where Turborepo comes in.

Where Turborepo earns its keep

A monorepo without a task runner gets slow. You don't want to rebuild the mobile app because you fixed a typo on the marketing site.

Caching by fingerprint

Turborepo hashes each task's inputs into a fingerprint. If it has seen that fingerprint before, it restores the outputs from cache and replays the logs instead of doing the work again. Their caching docs are clear on the deal you're making: tasks should be deterministic, and only the files you list under outputs get cached. Hold up your end and the second build of an unchanged package is close to instant.

The dependency graph, in one caret

{
  "$schema": "https://turborepo.dev/schema.json",
  "tasks": {
    "build": {
      "dependsOn": ["^build"],
      "outputs": ["dist/**", ".next/**", "!.next/cache/**", "!.next/dev/**"]
    },
    "lint": {},
    "typecheck": {
      "dependsOn": ["^build"]
    }
  }
}

That ^build is doing a lot of work for one character. Per the configuration reference, the caret means "wait for this task in my dependencies first." So when packages/types changes, everything downstream rebuilds. When it doesn't, nothing does. Turborepo figures out the graph. I don't sit there guessing.

Remote caching, once

Remote caching shares those fingerprints across machines, so your CI and your laptop stop redoing each other's work. It's an afternoon to set up, once, and it pays rent every day after.

What this looks like in a real build

Theory is cheap. Here's how the pattern held up in work that's public on this site.

  • A racket sports platform runs its apps and services from one Turborepo, sharing internal packages for types, UI and utilities. The shared packages use conditional exports, so in development an app imports straight from source and an edit to a shared button shows up with no rebuild step. In production, the built version ships. Same import, two behaviours.
  • Kyloth, the product I'm still building, keeps its Next.js application in a Bun and Turborepo workspace, with shared database and configuration packages as the foundation. It has not launched yet.

Different products, same skeleton. That's the point of a boring layout. It travels.

And when the mobile app arrives, it slots into apps/mobile and imports the same types on day one. That's most of the reason one Expo codebase for both app stores works so well for me.

Be honest, you might not need this yet

Here's where I disagree with the monorepo fans. One tiny app does not need one. A single Next.js site with a few routes and a database is perfectly happy alone. Reaching for Turborepo there is like buying a forklift to carry one grocery bag. You feel very serious and you've solved nothing.

The math flips the second you have two things that share code. A web app and a mobile app. An API and a client. A dashboard and a public site pulling from the same design tokens, the kind of setup I describe in design systems that earn their keep. The day a client says "can we add an app version," the shared package is already there, typed and tested, and "later" takes days instead of a rewrite.

Prove that the cache knows what changed

A fast green build is only useful if it built the right thing. Try this exercise on a disposable branch:

  1. Build twice without changing inputs. The second run should reuse eligible tasks.
  2. Change a shared validation rule. Its dependent apps should rebuild or recheck as configured.
  3. Change an environment variable that affects generated output. Confirm the relevant task misses the cache.
  4. Delete an output directory and rerun. Confirm the declared artifacts are restored, not just the success message.

If step three fails, inspect the task's declared environment inputs. If step four fails, inspect outputs. Turborepo's caching documentation explains the central constraint: a cache assumes deterministic work based on the inputs it knows about. An undeclared input is not magically discovered because the build feels important.

Keep secrets and sensitive generated artifacts out of shared cache entries. And separate repository consistency from deployment compatibility: the API can deploy today while an older mobile app remains installed for weeks. One codebase for both stores still needs a release strategy. One repository removes duplicated work; it does not synchronise every phone on Earth.

Frequently asked questions

Does a small team need a monorepo?

Team size isn't the trigger. Shared code is. A solo founder shipping web plus mobile gets more out of one repo than a ten-person team maintaining a single site. If two of your apps keep copying the same types back and forth, you already need it, whatever the headcount.

When should I not use one?

Skip it when you have exactly one app and no plans for a second, or when your services belong to separate teams that deploy on their own clocks and never share a type. A monorepo assumes shared ownership and shared cadence. Force it onto teams without those, and you've bought coordination pain with no payoff.

Does a monorepo slow down my builds?

Without a task runner, it can. Everything in one place tempts every tool to look at everything. Turborepo fixes that by fingerprinting each task and restoring cached results when nothing relevant changed, so unchanged packages stop costing you build time.

How do I keep it from becoming a mess?

Draw the line between apps and packages, and never let an app import another app. Apps sit at the top and consume. Packages sit below and provide. Keep that arrow pointing one way, and enforce it in the build rather than in code review, and the repo stays legible for years.

Do I need Turborepo specifically?

No. Workspaces from your package manager give you the shared packages, and other task runners exist. I reach for Turborepo because the config stays small, the caching is easy to reason about, and it's the tool in my public builds, so I know where its edges are.

One source of truth, defended by the compiler

Most codebases rot because the truth lives in four places and only one of them gets updated. A monorepo with a shared types package puts the truth in one place and makes the compiler defend it. You move faster because a whole category of bug never gets the chance to exist.

I set this up on day one for anyone building more than a single screen, and the full toolkit I reach for is on my stack page. If that sounds like your project, tell me what you're building, and I'll tell you honestly whether you need one repo or just one app.

Was this useful?

No account needed. One like per browser; click again to undo.

ShareXLinkedInFacebook
Prabir Singh, profile photo

Prabir Singh

Full-stack engineer in Mumbai. Twenty years in sales taught me why people buy; seven years of code taught me how to build what they'll pay for. I still read error messages the way I once read objections: as the most honest feedback of the day. More about me or start a project.

Keep reading