Skip to content

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.

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,
},
});
const hd = yield* Cloudflare.Hyperdrive.bind(MyDB);
const url = yield* hd.connectionString;