I just started a new project a few days ago. It got me wondering: how would I have built this without using monorepos? π€.
Essentially, it was an API-first project, meaning most users were going to interact with the app through the API. But having a decent dashboard was equally important as well.
So what do we do? Create an API project, a dashboard project, a landing page project, and a documentation project. What about internal packages? Even writing about how I was planning to do this is painful, lol.
If you have a similar story, thatβs where something like a monorepo comes into the picture. In simple terms, monorepos are mono repositories, meaning they contain multiple projects within a single repository.
Having a structure like a monorepo, where most of your apps are inside the same repository, means they can easily share internal packages across these projects.
Now let's get to the juicy part. How do you create a Monorepo? Thatβs where services like Turbrepo come into picture.
turborepo/
βββ apps/
β βββ api/ API application
β βββ dashboard/ Dashboard application
β βββ www/ landing page application
βββ internal/ Internal packages
βββ packages/ Packages pushed on npm
βββ .env
βββ .gitignore
βββ package.json
βββ pnpm-lock.yaml
βββ pnpm-workspace.yaml
βββ turbo.json
This is one of my recent projects. In the initial stages, deployment, testing, and development are really fast with this monorepo structure. However, as you grow, the app will need to rebuild and redeploy itself even for a simple typo. So use it at your own risk.
But here is how you can quickly get started:
pnpm dlx create-turbo@latest
Name the project:
? Where would you like to create your Turborepo? (./my-turborepo)
Select the package manager:
? Which package manager do you want to use? (Use arrow keys)
β― npm
pnpm
yarn
- Bun (beta) (not installed)
and you are all set! You should have something looking like this:
turborepo/
βββ .vscode/
βββ apps/
β βββ docs/
β βββ web/
βββ packages/
βββ .gitignore
βββ .npmrc
βββ package.json
βββ pnpm-lock.yaml
βββ pnpm-workspace.yaml
βββ README.md
βββ turbo.json
Make changes to this app based on your requirements, and enjoy faster, more maintainable projects! π