just appjust lint-js
just lint-js-fix # with auto-fix-
Create the database in Cloudflare Dashboard
- Go to Cloudflare Dashboard
- Navigate to Workers & Pages → D1 SQL Database
- Click Create Database
- Name:
deep-sentiment-db - Copy the Database ID and update it in
wrangler.jsonc
-
Initialize the database
just db-init # Initialize remote database just db-init-local # Initialize local database
just db-init # Initialize remote database with schema
just db-init-local # Initialize local database with schema
just db-query "SELECT * FROM counter" # Query remote database
just db-query-local "SELECT * FROM counter" # Query local databaseTo test D1 locally, you must use bunx wrangler dev instead of the normal bun run dev:
just dev # Development server with D1 (local database)
just dev-remote # Development server with D1 (remote database)Then visit http://localhost:8787/counter-test to see the counter demo.
Note: The regular just app command won't have access to D1 bindings.
just deploy # Build and deploy to Cloudflare Workers- GET
/api/counter- Get current count - POST
/api/counter- Increment count - DELETE
/api/counter- Reset to 0
Visit /counter-test to see the D1 integration demo.
src/
├── app.d.ts # TypeScript types (includes D1)
└── routes/
├── api/
│ └── counter/
│ └── +server.ts # Counter API endpoint
└── counter-test/
└── +page.svelte # Counter demo page
- Ensure
database_idis updated inwrangler.jsonc - Use
bunx wrangler dev(notbun run dev) for D1 testing - Run
just db-init-localto initialize local database
- Local database (
--local): Stored in.wrangler/state/v3/d1 - Remote database (
--remote): Your production Cloudflare D1 database - Make sure you're testing against the right one