https://github.com/nacal/nextjs-cloudflare-pages-d1-drizzle-template
https://github.com/nacal/nextjs-cloudflare-pages-d1-drizzle-template
Last synced: 22 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/nacal/nextjs-cloudflare-pages-d1-drizzle-template
- Owner: nacal
- Created: 2025-04-27T11:15:14.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2025-05-01T14:56:23.000Z (about 1 month ago)
- Last Synced: 2025-05-11T07:16:55.714Z (22 days ago)
- Language: TypeScript
- Size: 348 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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](https://developers.cloudflare.com/d1/get-started/#2-create-a-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```json
{
"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"
}
}
```8. Generate db migration files
```shell
pnpm db:generate
```8. Run db migrations
- local db: `pnpm db:migrate:local`
- preview db: `pnpm db:migrate:preview`
- production db: `pnpm db:migrate:prod`9. 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
```shell
pnpm dev
```- Run the app in cloudflare pages locally
```shell
pnpm pages:dev
```## Deploying to Cloudflare
- Deploy to production environment
```shell
pnpm pages:deploy
```- Deploy to preview environment
```shell
pnpm pages:deploy:preview
```