Skip to content
New to BhaiCode? Install the desktop app in under a minute, or build in your browser with Cloud Studio.
BhaiCode Docs
BhaiCode Docs
Databases & Storage › Cloudflare D1 (Edge SQLite)

Cloudflare D1 (Edge SQLite)

Ultra-low-latency edge SQLite that runs alongside Cloudflare Workers.

Cloudflare D1 is a serverless, edge-native relational database co-located with Cloudflare Workers. Reads are served close to the user, typically with sub-5 ms latency.

Highlights

  • Low latency: queries execute on edge nodes near the reader.
  • Standard SQL: SQLite dialect with joins, indexes, transactions, and JSON operators.
  • Drizzle integration: typed schema and queries out of the box.
db/schema.ts
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";

export const products = sqliteTable("products", {
  id: text("id").primaryKey(),
  name: text("name").notNull(),
  priceInCents: integer("price_in_cents").notNull(),
  createdAt: integer("created_at", { mode: "timestamp" })
    .$defaultFn(() => new Date())
    .notNull(),
});

Provision it

Open the Databases drawer in Cloud Studio and select Cloudflare D1, or connect the provider first. BhaiCode binds the D1 binding and installs Drizzle.

Was this page helpful?