Cloudflare.Hyperdrive reference
Connect
Section titled “Connect”Source:
src/Cloudflare/Hyperdrive/Connect.ts
A typed accessor for a Cloudflare Hyperdrive runtime binding inside a
Worker. Provides the same shape as the raw Hyperdrive runtime object
(connection string, host, port, user, password, database) plus a raw
escape hatch for libraries that want direct access.
Connect: Examples
Section titled “Connect: Examples”Bind Hyperdrive in a Worker
const hd = yield* Cloudflare.Hyperdrive.Connect(MyConnection);const url = yield* hd.connectionString;/
/**
Bind a Connection to a Worker and obtain the Effect-native
Hyperdrive client (connection string, host, port, …).
Connect is a single identifier that is simultaneously the binding’s Context
tag, its type, and the callable — yield* Cloudflare.Hyperdrive.Connect(conn).
Using Hyperdrive inside a Worker
const hd = yield* Cloudflare.Hyperdrive.Connect(MyConnection);const url = yield* hd.connectionString;Connection
Section titled “Connection”Source:
src/Cloudflare/Hyperdrive/Connection.ts
A Cloudflare Hyperdrive configuration.
Hyperdrive accelerates and pools connections to existing PostgreSQL or MySQL databases, exposing them to Workers via a binding. Create a config as a resource, then bind it to a Worker to obtain a connection string.
Connection: Creating a Hyperdrive
Section titled “Connection: Creating a Hyperdrive”const hd = yield* Cloudflare.Hyperdrive.Connection("my-pg", { origin: { scheme: "postgres", host: "db.example.com", port: 5432, database: "app", user: "app", password: yield* Config.Redacted("DB_PASSWORD"), },});Connection: Binding to a Worker
Section titled “Connection: Binding to a Worker”const hd = yield* Cloudflare.Hyperdrive.Connect(MyConnection);const url = yield* hd.connectionString;