Storage
Hyperdrive
Use a Hyperdrive binding with OpenOrange. The Worker connects directly to the database.
Status: Supported. The Worker connects directly to the database.
Choose a provider
Any PostgreSQL or MySQL database works. Use its connection string as the local connection string:
| Provider | Connection string | Notes |
|---|---|---|
| PlanetScale Postgres | postgresql://<role>.<branch ID>:<password>@<host>.horizon.psdb.cloud:5432/<database>?sslmode=verify-full | Copy the host from the Connect page. |
| PlanetScale MySQL | mysql://<user>:<password>@<host>/<database> | Copy the host from the Connect page, with the Other format. |
| Amazon RDS | postgres://<user>:<password>@<instance>.<ID>.<region>.rds.amazonaws.com:5432/<database> | For MySQL, use mysql:// and port 3306. The instance must accept connections from the runner. |
| Neon | postgresql://<role>:<password>@ep-<compute ID>.<region>.aws.neon.tech/<database>?sslmode=require | A -pooler host, such as ep-<compute ID>-pooler, uses Neon’s connection pooler. |
| Supabase | postgresql://postgres:<password>@db.<project ref>.supabase.co:5432/postgres | The direct host uses IPv6 on the Free and Pro plans. On an IPv4-only network, use the session pooler: postgresql://postgres.<project ref>:<password>@<pooler host>:5432/postgres. |
| A database that you run | postgres://<user>:<password>@localhost:5432/<database> |
OpenOrange has no connection pool, so each connection that the Worker opens goes to the
database. A provider’s pooler, such as Neon’s -pooler host or the Supabase pooler,
can take more connections than the database itself.
Configuration
OpenOrange reads the standard Wrangler hyperdrive configuration:
{
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<HYPERDRIVE_ID>",
"localConnectionString": "postgres://user:password@localhost:5432/app"
}
]
}
orange dev finds the connection string the same way as wrangler dev:
- The
CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING>variable. - The deprecated
WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING>variable.orange devprints a deprecation warning. localConnectionStringin the configuration.
The variables can come from the shell, .dev.vars, or .env. If no
connection string is set, orange dev stops with the Wrangler error.
Usage
Worker code runs unchanged:
import postgres from "postgres";
export default {
async fetch(request, env) {
const sql = postgres(env.HYPERDRIVE.connectionString);
const rows = await sql`select now()`;
return Response.json(rows);
},
};
env.HYPERDRIVE has the same shape as the workerd Hyperdrive type:
| Property | Type | Value |
|---|---|---|
connectionString | string | The connection string. |
host | string | The database host. |
port | number | The URL port, else 5432 for postgres/postgresql and 3306 for mysql. |
user | string | The URL-decoded user name. |
password | string | The URL-decoded password. |
database | string | The URL-decoded database name. |
connect() | Socket | A TCP socket to host:port. |
OpenOrange checks the connection string with Miniflare’s rules. It must use
the postgres, postgresql, or mysql scheme and include a host, user,
password, and database.
Differences from Cloudflare
- The Worker connects directly to the database. There is no connection pooling and no query caching.
hostandportname the database itself. On Cloudflare they name a Hyperdrive endpoint.
Compatibility
From the latest conformance run. Scores on the compatibility page; every binding on the status page.
Hyperdrive
hyperdrive Runs on Direct connection to the database in the connection string.
Connects directly; no pooling or query cache
Works with
Any Postgres or MySQL connection string, as in your Wrangler config.
In the feature matrix
SupportedhyperdriveGives a pooled, cached connection string for a remote database.Exposes connectionString, host, port, user, password, database, and connect() for the local database, like wrangler dev. Reads CLOUDFLARE_HYPERDRIVE_LOCAL_CONNECTION_STRING_<BINDING> (or the deprecated WRANGLER_ prefix), then localConnectionString. 4 files
- Notes
- Connects directly; no connection pooling or query caching. A missing connection string fails startup with the Wrangler error. host and port name the database itself, not a Hyperdrive proxy.
- Source
- packages/runtime-node/src/bindings/hyperdrive.ts:1-84src/config/load-wrangler.ts:706-748packages/runtime-node/src/runner.ts:466-468tests/hyperdrive.test.ts