TypeScript or nothing
One language from the phone to the database. Why every project I take on is TypeScript end to end, and why I stopped apologising for it.
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.

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.
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.
| Path | What it is | Built with |
|---|---|---|
apps/web | The marketing site and dashboard | Next.js or TanStack Start |
apps/mobile | iOS and Android from one codebase | Expo |
apps/api | The server the other two talk to | Hono |
packages/types | Shared types and validation | TypeScript, Zod |
packages/db | Schema and queries | Drizzle, Postgres |
packages/ui | Shared components and tokens | React, Tailwind |
packages/config | ESLint, TS, Tailwind presets | plain 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.
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.
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.
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.
| Several repos | One monorepo | |
|---|---|---|
| Changing a shared field | One PR per repo, plus a version bump | One PR |
| Where types live | Copied, and drifting | One package, imported everywhere |
| When a mismatch shows up | Runtime, often in production | Compile time, on your screen |
| Build speed without tooling | Each repo cold-starts its own pipeline | Slow, until you add a task runner |
| Ownership model | Fits teams that never share code | Fits 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.
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.
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.
{
"$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 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.
Theory is cheap. Here's how the pattern held up in work that's public on this site.
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.
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.
A fast green build is only useful if it built the right thing. Try this exercise on a disposable branch:
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.
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.
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.
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.
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.
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.
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.
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.
One language from the phone to the database. Why every project I take on is TypeScript end to end, and why I stopped apologising for it.
Express shaped a generation of Node APIs. Why my new backends start with Hono instead, where it changes how I build, and when Express still wins.
Server Components confuse people because the mental model is missing. Here's the kitchen picture that makes the split click, and the rules that keep it clean.