Skip to content

yusukebe/cloudflare-d1-drizzle-honox-starter

Repository files navigation

cloudflare-d1-drizzle-honox-starter

A starter project showing how you can integrate Drizzle ORM and Cloudflare D1 with a HonoX application to build awesome full-stack apps.

Tip

If the above paragraph was a bunch of buzzwords that seem confusing, here's the simple version:

  • HonoX is a full-stack framework combining backend API endpoints with the ability to render frontend applications with React
  • Cloudflare D1 is a SQL database
  • Drizzle ORM provides an ORM wrapper around D1, to allow data models and querying using a straightforward syntax

Installation

0. Clone the template and install all dependencies

git clone [email protected]:yusukebe/cloudflare-d1-drizzle-honox-starter.git starter
cd starter
npm install

1. Create a new D1 database using Wrangler

npx wrangler@latest d1 create d1-todo

Note that if you haven't yet used Wrangler, you will be prompted to login to Cloudflare.

Copy the output of this command, which is structured TOML configuration, into your wrangler.toml.

2. Create a new migration file

npm run migration:generate

3. Apply the migration to your local database

npm run migration:apply:local

4. When you're ready, deploy your application

npm run deploy

5. Once you've deployed your application, you can apply the migrations to your remote (production) D1 database

npm run migration:apply:remote

Prisma Version

You can see the starter using Prisma instead of Drizzle ORM:

Author

Yusuke Wada https://github.com/yusukebe

License

MIT