/project-zen

Primary LanguageTypeScript

This is a boilerplate for a Next.js project with Cloudflare Pages, D1, and Drizzle ORM.

Getting Started

  1. Create a new project on Github using this template
  2. Clone the repository to your local machine
  3. Install the dependencies using npm install
  4. Create a D1 database
  5. Rename .env.example to .env and set the environment variables
  6. Rename wrangler.toml.example to wrangler.toml and set the environment variables
  7. Modify the package.json file with your database name
{
  "scripts": {
    "db:migrate:local": "wrangler d1 migrations apply my-database-name --local",
    "db:migrate:preview": "wrangler d1 migrations apply --env preview my-preview-database-name --remote",
    "db:migrate:prod": "wrangler d1 migrations apply my-database-name --remote"
  }
}
  1. Generate db migration files
pnpm db:generate
  1. Run db migrations
  • local db: pnpm db:migrate:local
  • preview db: pnpm db:migrate:preview
  • production db: pnpm db:migrate:prod
  1. View the database using drizzle studio
  • local db: pnpm db:studio:local
  • preview (remote) db: pnpm db:studio:preview
  • production (remote) db: pnpm db:studio:prod

Running the app

  • Run the app in development mode
pnpm dev
  • Run the app in cloudflare pages locally
pnpm pages:dev

Deploying to Cloudflare

  • Deploy to production environment
pnpm pages:deploy
  • Deploy to preview environment
pnpm pages:deploy:preview