cloudflare-d1-prisma-honox-starter
A starter project showing how you can integrate Prisma 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
- Prisma provides an ORM wrapper around D1, to allow data models and querying using a straightforward syntax
$ git clone https://github.com/kristianfreeman/cloudflare-d1-prisma-honox-starter starter
$ cd starter
$ npm install
$ npx wrangler@latest d1 create starter # or name it something of your choice
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
.
d1 migrations
subcommand:$ npx wrangler d1 migrations create starter create_tables
$ npx prisma migrate diff \
--from-empty \
--to-schema-datamodel ./prisma/schema.prisma \
--script \
--output migrations/0001_create_tables.sql
$ npx prisma generate
$ npx wrangler@latest d1 migrations apply cdph-starter
$ npx wrangler@latest deploy
$ npx wrangler@latest d1 migrations apply cdph-starter --remote