Hyperdrive
Source:
src/Cloudflare/Hyperdrive/Hyperdrive.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.
Creating a Hyperdrive
Section titled “Creating a Hyperdrive”const hd = yield* Cloudflare.Hyperdrive("my-pg", { origin: { scheme: "postgres", host: "db.example.com", port: 5432, database: "app", user: "app", password: alchemy.secret.env.DB_PASSWORD, },});Binding to a Worker
Section titled “Binding to a Worker”const hd = yield* Cloudflare.Hyperdrive.bind(MyDB);const url = yield* hd.connectionString;