πΎ Cloudflare D1 Backend
For more info, see the official Cloudflare D1 docs (opens in a new tab).
Create a database
Preview Database
Create a preview database with some name.
wrangler d1 create PREV_DATABASE_NAMEProduction Database
Create a production database with some other name.
wrangler d1 create PROD_DATABASE_NAMEDatabase IDs
The output of these commands will look like this:
β
Successfully created DB 'DATABASE_NAME'
[[d1_databases]]
binding = "DB"
database_name = "DATABASE_NAME"
database_id = "unique-id-for-your-database"You'll need this output to bind the created databases to the worker, take note of the database_ids.
Environment Variable
For development set the DATABASE_ID environment variable inside the .env.local file to the preview database one.
Then run bun install again to generate the correct .dev.vars file under packages/api/. For a better explanation of this refer to the development section.