Monorepo with Vercel and AWS
GitHub repositoryOverview
A repository demoing how Vercel can work with subapps and subpaths on other hosting providers.
Architecture
This repository contains two applications, each with an independent deployment:
All three applications are managed in a single monorepo by Turborepo, facilitating shared dependencies across the project under the /packages folder. The header component, as well as other resources like global styles are shared across the different applications. Changes to these shared resources will cause both applications to redeploy.
Nginx Reverse Proxy Setup
Warning
- Purpose: An Nginx reverse proxy has been set up on an AWS EC2 instance and placed in front of both applications. This setup ensures that all two applications are accessible from a unified domain (monorepo-vercel-amplify.com), with the reverse proxy directing traffic between them.
- Configuration:
- Requests to
/dashboardare routed to App 2 (Dashboard). - Requests to
/are routed to App 1 (Web).
- Requests to
Using this example
This example uses pnpm as package manager.
Clone the repository:
git clone https://github.com/vercel-saleseng/monorepo-vercel-amplify
Install dependencies:
cd monorepo-vercel-amplify pnpm install
Add ui components
Use the pre-made script:
pnpm ui:add <component-name>
This works just like the add command in the shadcn/ui CLI.
Add a new app
Turborepo offer a simple command to add a new app:
pnpm turbo gen workspace --name <app-name>
This will create a new empty app in the apps directory.
If you want, you can copy an existing app with:
pnpm turbo gen workspace --name <app-name> --copy
Remember to run pnpm install after copying an app.
Build
To build all apps and packages, run the following command:
cd monorepo-vercel-amplify pnpm build
Develop
To develop all apps and packages, run the following command:
cd monorepo-vercel-amplify pnpm dev
Useful Links
Learn more about the power of Turborepo:
Learn more about shadcn/ui:
Original template: