A monorepo template using Yarn workspaces and TypeScript, featuring a shared common package, backend API, and frontend application. This supports hot reloading (even for shared packages) for development.
yarn-ts-monorepo/
├── packages/
│ ├── common/ # Shared types and utilities
│ ├── backend/ # Express.js API server
│ └── frontend/ # React frontend application
├── package.json # Root package.json
├── tsconfig.json # Root TypeScript configuration
└── docker-compose.yml # Docker Compose configuration
- Docker
- Docker Compose
- Clone the repository:
git clone <repository-url>
cd yarn-ts-monorepoThis repo supports running in development mode, which supports hot reloading of the front-end and backend.
docker compose --profile dev up --buildWhen running in development mode, the frontend and backend run in a single container. The files on your local machine get volume mounted into the container. This allows you to make changes locally, and have them immediately update the running stack. You can even make changes in the common package, and see these changes immediately as well.
This repo also supports a more "production" like run mode, where the frontend and backend run in separate containers running compiled code.
docker compose --profile prod up --buildThis will start:
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000
The common package contains shared types and utilities used by both the frontend and backend.
The backend is an Express.js server that provides a REST API. Features:
- TypeScript support
- CORS enabled for frontend development
- Shared types from common package
The frontend is a React application built with Vite. Features:
- TypeScript support
- React Router for navigation
- Shared types from common package
docker compose --profile dev up- Start up development containerdocker compose --profile dev up --build- Rebuild and start development containerdocker compose --profile prod up- Start up production containersdocker compose --profile prod up --build- Rebuild and start up production containerdocker compose down- Stop all services
The project uses a base TypeScript configuration in the root tsconfig.json that is extended by each package.
This ensures consistent TypeScript settings across the monorepo.