Create a Hyperdrive config for Postgres

d1 & hyperdrive

// what it does

Creates a Hyperdrive config that pools and caches connections to an existing Postgres (or MySQL — use a mysql:// connection string) origin, so a Worker gets warm connections instead of a fresh TLS+auth round-trip per request. Prints a config id for the [[hyperdrive]] binding; --update-config writes that binding into your wrangler config automatically.

// shell

$ wrangler hyperdrive create <name> --connection-string="postgres://user:[email protected]:5432/postgres"
$ wrangler hyperdrive create <name> --connection-string="postgres://user:password@host:5432/dbname" --update-config

// gotcha

The origin password is baked into the stored config and is not shown again by hyperdrive get. In local wrangler dev, Hyperdrive can't tunnel to your database — set WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING> to a reachable connection string for local runs.