- Node.js >=v20.11.0
- pnpm >=v8.15.4
- Create a D1 database.
- Create a
.env
file and awrangler.toml
file with the necessary information (e.g., find and replace all "TBA" and "nextjs-d1-drizzle-cloudflare-pages" values in the code). - Install the app's dependencies:
pnpm install
- Generate db migration files (which are SQL queries that will be run on the databases to update their tables in the next step):
pnpm db:generate
- Run db migrations:
- local db:
pnpm db:migrate:local
- preview (remote) db:
pnpm db:migrate:preview
- prod (remote) db:
pnpm db:migrate:prod
- View the database using a graphical user interface:
- local db:
pnpm db:studio:local
- preview (remote) db:
pnpm db:studio:preview
- prod (remote) db:
pnpm db:studio:prod
- Run Next.js on dev. Ideal for development since it supports hot-reload/fast refresh.
pnpm dev
next start
will return an error due to how the application is designed to run on
Cloudflare pages.
- Run Cloudflare Pages locally. Ideal to test how the app would work after being deployed.
pnpm pages:dev
- Deploy code to pages:
pnpm pages:deploy