Add a New Application to Your Makerkit Monorepo
Create additional applications in your Turborepo monorepo using git subtree to maintain updates from Makerkit while building separate products.
Add new applications to your Makerkit monorepo using git subtree to clone the apps/web template while maintaining the ability to pull updates from the Makerkit repository. This is useful for building multiple products (e.g., a main app and an admin dashboard) that share the same packages and infrastructure.
Advanced Topic
This guide is for advanced use cases where you need multiple applications in a single monorepo. For most projects, a single apps/web application is sufficient. Creating a separate repository may be simpler if you don't need to share code between applications.
Add a Turborepo Application
Create a new application from the web template
When to Add a New Application
Add a new Turborepo application when:
- Multiple products: You're building separate products that share authentication, billing, or UI components
- Admin dashboard: You need a separate admin interface with different routing and permissions
- API server: You want a dedicated API application separate from your main web app
- Mobile companion: You're building a React Native or Expo app that shares business logic
Keep a single application when:
- You only need one web application
- Different features can live under different routes in
apps/web - Separation isn't worth the complexity
Step 1: Create the Subtree Branch
First, create a branch that contains only the apps/web folder. This branch serves as the template for new applications.
git subtree split --prefix=apps/web --branch web-branchThis command:
- Extracts the history of
apps/webinto a new branch - Creates
web-branchcontaining only theapps/webcontents - Preserves commit history for that folder
Step 2: Add the New Application
Create your new application by pulling from the subtree branch.
For example, to create a pdf-chat application:
git subtree add --prefix=apps/pdf-chat origin web-branch --squashThis command:
- Creates
apps/pdf-chatwith the same structure asapps/web - Squashes the history into a single commit (cleaner git log)
- Sets up tracking for future updates
Verify the Application
ls apps/pdf-chatYou should see the same structure as apps/web:
apps/pdf-chat/├── app/├── components/├── config/├── lib/├── supabase/├── next.config.mjs├── package.json└── ...Step 3: Configure the New Application
Update package.json
Change the package name and any app-specific settings:
apps/pdf-chat/package.json
{ "name": "pdf-chat", "version": "0.0.1", "scripts": { "dev": "next dev --port 3001", "build": "next build", "start": "next start --port 3001" }}Update Environment Variables
Create a separate .env.local for the new application:
apps/pdf-chat/.env.local
NEXT_PUBLIC_SITE_URL=http://localhost:3001NEXT_PUBLIC_APP_NAME="PDF Chat"# ... other environment variablesUpdate Supabase Configuration (if separate)
If the application needs its own database, update apps/pdf-chat/supabase/config.toml with unique ports and project settings.
Add Turbo Configuration
Update the root turbo.json to include your new application:
turbo.json
{ "pipeline": { "build": { "dependsOn": ["^build"], "outputs": [".next/**", "!.next/cache/**"] }, "pdf-chat#dev": { "dependsOn": ["^build"], "persistent": true } }}Run the New Application
# Run just the new apppnpm --filter pdf-chat dev# Run all apps in parallelpnpm devStep 4: Pulling Updates
When Makerkit releases updates, follow these steps to sync them to your new application.
Pull Upstream Changes
First, pull the latest changes from Makerkit:
git pull upstream mainUpdate the Subtree Branch
Re-extract the apps/web folder into the subtree branch:
git subtree split --prefix=apps/web --branch web-branchPush the Branch
Push the updated branch to your repository:
git push origin web-branchPull Into Your Application
Finally, pull the updates into your new application:
git subtree pull --prefix=apps/pdf-chat origin web-branch --squashResolve Conflicts
If you've modified files that were also changed upstream, you'll need to resolve conflicts:
# After conflicts appeargit status # See conflicted files# Edit files to resolve conflictsgit add .git commit -m "Merge upstream changes into pdf-chat"Update Workflow Summary
# 1. Get latest from Makerkitgit pull upstream main# 2. Update the template branchgit subtree split --prefix=apps/web --branch web-branchgit push origin web-branch# 3. Pull into each additional appgit subtree pull --prefix=apps/pdf-chat origin web-branch --squashgit subtree pull --prefix=apps/admin origin web-branch --squashTroubleshooting
"fatal: refusing to merge unrelated histories"
Add the --squash flag to ignore history differences:
git subtree pull --prefix=apps/pdf-chat origin web-branch --squashSubtree branch doesn't exist on remote
Push it first:
git push origin web-branchApplication won't start (port conflict)
Update the port in package.json:
{ "scripts": { "dev": "next dev --port 3001" }}Shared packages not resolving
Ensure the new app's package.json includes the workspace dependencies:
{ "dependencies": { "@kit/ui": "workspace:*", "@kit/supabase": "workspace:*" }}Then run pnpm install from the repository root.
Related Resources
- Adding Turborepo Packages for creating shared packages
- Technical Details for monorepo structure
- Clone Repository for initial setup