This starter makes it easy to start up a project with database using Drizzle.
Create your new project:
npx degit redwoodjs/example-drizzle my-project-name
cd my-project-name
pnpm installpnpm devPoint your browser to the URL displayed in the terminal (e.g. http://localhost:5173/). You should see a "Hello World" message in your browser.
Within your project's wrangler.jsonc file, replace the placeholder values. For example:
You'll need a Cloudflare account as this starter uses Cloudflare D1 for the database.
Create a new D1 database:
npx wrangler d1 create my-project-dbCopy the database_id from the output and paste it into:
- Your project's
wrangler.jsonfile - The
.envfile (copy from.env.example)
CLOUDFLARE_ACCOUNT_ID=your-account-id
CLOUDFLARE_DATABASE_ID=your-database-id
CLOUDFLARE_D1_TOKEN=your-api-token
To get your Cloudflare credentials:
- Account ID: Find this under Workers & Pages in your Cloudflare dashboard
- API Token: Generate this under User Profile > API Tokens with the following permissions:
- Account Settings: Read
- D1: Edit
The starter includes a basic user model in src/db/schema.ts:
export const users = sqliteTable("users", {
id: text("id").primaryKey(),
name: text("name").notNull(),
email: text("email").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" })
.notNull()
.default(sql`CURRENT_TIMESTAMP`),
});When you need to make changes to your database schema:
- Update your schema in
src/db/schema.ts - Run
pnpm migrate:newto create a new migration - Run
pnpm migrate:devto apply the migration
VS Code extensions that make development easier:
For database management, we recommend Bee Keeper Studio.

{ "name": "my-project-name", "main": "src/worker.tsx", "compatibility_date": "2024-09-23", "compatibility_flags": ["nodejs_compat"], "d1_databases": [ { "binding": "DB", "database_name": "my-project-db", "database_id": "YOUR-DB-ID-HERE", "migrations_dir": "drizzle", }, ], }