A small D1 example you can adapt quickly
This starter example keeps D1 focused on one job: answer a single query and prove the binding works locally.
You do not need a giant ORM story to prove D1 is wired correctly. One table-shaped query is already enough to make the point.
- Config focus
- Stable database naming
- Runtime shape
- Prepared statement query in a fetch handler
- Best use
- Health checks, small lookup routes, and early schema experiments
Start by wiring the binding clearly in config
Minimal D1 config
Then use it in one honest runtime path
- You can replace the health query with a real table lookup later without changing the binding shape.
- Keep one route like this around if you want a cheap deploy smoke path for D1.
A tiny route that proves the binding works
Lock in the behavior with one small test or smoke path
The first example does not need a migration epic
Prove the binding first. Add richer schema setup only after the worker already has one truthful D1 path.
A matching smoke test
Previous
Testing D1
D1 is one of the easiest bindings to test meaningfully with Devflare because the local runtime already speaks the same database API your worker uses.
Next
R2
R2 is straightforward in config and well-supported locally, but browser-facing delivery should usually go through a Worker route instead of assuming bucket URLs.