Monorepo architecture in shadcn-ui/ui.
Tags: javascript, opensource, shadcnui, nextjs
Published: 2024-05-20 22:37:13

In this article, you will learn the following concepts used to build Shadcn-ui/ui:

1.  Tool used for monorepo architecture is Turbo.
2.  What is Turbo?
3.  Next.js + Turbo example.
4.  Folder structure difference between Next.js + Turbo and the Shadcn-ui/ui.

Tool used for monorepo architecture is Turbo:
---------------------------------------------

Pick any open source project, begin with reviewing the file structure to understand the project configuration. You will find all sorts of folders and files related to tooling. Shadcn-ui/ui uses [Turbo](https://turbo.build/) for its monorepo architecture. It is evident from the existence of [turbo.json](https://github.com/shadcn-ui/ui/blob/main/turbo.json) file and the commands used in “scripts” in [package.json](https://github.com/shadcn-ui/ui/blob/main/package.json).

What is Turbo?
--------------

[Turbo](https://turbo.build/) is an incremental bundler and build system optimized for JavaScript and TypeScript, written in Rust from Vercel.

I recommend reading the [turbo documentation](https://turbo.build/pack/docs) for more information.

The following reasons are picked from [turbo.build](http://turbo.build) website as to why to choose Turbo.

1.  Incremental by design
2.  Ecosystem-friendly
3.  Lightning fast HMR
4.  React Server Components
5.  Simultaneous Multiple Env Targets
6.  Next.js support

Next.js + Turbo example:
------------------------

[Start from example section](https://turbo.build/repo/docs/getting-started/from-example) on the [turbo.build](http://turbo.build) provides one of the examples that involves Next.js usage. It is a [Turborepo starter with Next.js](https://github.com/vercel/turbo/tree/main/examples/basic)

[![](https://media.licdn.com/dms/image/D4E12AQGwIrqOt5HtfQ/article-inline_image-shrink_1500_2232/0/1716243322578?e=1721865600&v=beta&t=Ua-ULvltH6bnjKVy8QtWOemxli54u3vvtgs_bQpKAV0)](https://tthroo.com)

Folder structure difference between Next.js + Turbo and the Shadcn-ui/ui:
-------------------------------------------------------------------------

Folder structure of basic example provided by Turborepo with Next.js:

![](https://media.licdn.com/dms/image/D4E12AQEFeF7s1MVuGA/article-inline_image-shrink_1000_1488/0/1716243324155?e=1721865600&v=beta&t=EJYyL-Y0YWTV8CUfxWMw3VfEZj60ml4q-uPSRF41bMo)

Folder structure of Shadcn-ui/ui

![](https://media.licdn.com/dms/image/D4E12AQFrZYgaJPybuQ/article-inline_image-shrink_1500_2232/0/1716243323022?e=1721865600&v=beta&t=HvW0UZv_OT8V8mu3qrQFTSyRLJScW6-B46iq8gYsnaM)

You do not strictly have to stick to the folders provided by the Turborepo starter pack, as you can see from the above screenshots, you are free to change the folder names inside apps/ and inside packages/ as you see fit for your applications.

Conclusion:
-----------

Pick any open source project, begin with reviewing the file structure to understand the project configuration. You will find all sorts of folders and files related to tooling. Shadcn-ui/ui uses [Turbo](https://turbo.build/) for its monorepo architecture. It is evident from the existence of [turbo.json](https://github.com/shadcn-ui/ui/blob/main/turbo.json) file and the commands used in “scripts” in [package.json](https://github.com/shadcn-ui/ui/blob/main/package.json).

About me:
---------

Website: [https://ramunarasinga.com/](https://ramunarasinga.com/)

Linkedin: [https://www.linkedin.com/in/ramu-narasinga-189361128/](https://www.linkedin.com/in/ramu-narasinga-189361128/)

Github: [https://github.com/Ramu-Narasinga](https://github.com/Ramu-Narasinga)

Email: [ramu.narasinga@gmail.com](mailto:ramu.narasinga@gmail.com)

References:
-----------

1.  [https://github.com/shadcn-ui/ui/blob/main/turbo.json](https://github.com/shadcn-ui/ui/blob/main/turbo.json)
2.  [https://github.com/shadcn-ui/ui/blob/main/package.json](https://github.com/shadcn-ui/ui/blob/main/package.json)
3.  [https://turbo.build/](https://turbo.build/)
4.  [https://turbo.build/pack/docs](https://turbo.build/pack/docs)
5.  [https://turbo.build/repo/docs/getting-started/from-example](https://turbo.build/repo/docs/getting-started/from-example)
6.  [https://github.com/vercel/turbo/tree/main/examples/basic](https://github.com/vercel/turbo/tree/main/examples/basic)