In progess!
This is turborepo starter with Drizzle ORM and PostgreSQL pre-configured.
Note
This example uses pnpm as package manager.
Clone the repository:
git clone https://github.com/htsh-tsyk/turbo-drizzle.gitThis Turborepo includes the following packages/apps:
web: another Next.js app@repo/database: Drizzle ORM wrapper to manage & access your database@repo/ui: a stub React component library shared by awebapplication@repo/eslint-config:eslintconfigurations (includeseslint-config-nextandeslint-config-prettier)@repo/typescript-config:tsconfig.jsons used throughout the monorepo
Each package/app is 100% TypeScript.
This Turborepo has some additional tools already setup for you:
- TypeScript for static type checking
- ESLint for code linting
- Prettier for code formatting
- Drizzle for database ORM for database ORM
To build all apps and packages, run the following command:
cd turbo-drizzle
cp apps/web/.env.default apps/web/.env
pnpm install
pnpm build
We use Drizzle ORM to manage & access our database. As such you will need a database for this project, either locally or hosted in the cloud.
To make this process easier, we offer a docker-compose.yml file to deploy a PostgreSQL server locally with a new database named repo_development (To change this update the POSTGRES_DB environment variable in the docker-compose.yml file):
cd turbo-drizzle
docker-compose up -dOnce deployed you will need to copy the .env.default file to .env in order for Drizzle to have a DATABASE_URL environment variable to access.
cp apps/web/.env.default apps/web/.envIf you added a custom database name, or use a cloud based database, you will need to update the DATABASE_URL in your .env accordingly.
Once deployed & up & running, you will need to create & deploy migrations to your database to add the necessary tables. This can be done using Drizzle Migrate:
in database package: (command drizzle-kit generate)
pnpm generate
pnpm turbo db:migrateAn optional additional step is to seed some initial or fake data to your database.
To do this update check the seed script located in packages/database/scripts/seed.ts & add or update any users you wish to seed to the database.
Once edited run the following command to run tell Drizzle to run the seed script defined in the Drizzle configuration:
pnpm turbo db:seedTo develop all apps and packages, run the following command:
pnpm devLearn more about the power of Turborepo:
- Drizzle Turbo Repo Template: https://github.com/htsh-tsyk/turbo-drizzle/tree/main
- Next.js Clean Architecture: https://github.com/nikolovlazar/nextjs-clean-architecture/tree/main
- Next.js 15 on turborepo template: https://github.com/vercel/turborepo/tree/c59da312df134cc1aaf7c269bc3cd0b78c073b07/examples/basic