Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/cloudflare/workers-sdk/llms.txt

Use this file to discover all available pages before exploring further.

Hyperdrive accelerates access to your existing databases from Cloudflare Workers, making even geographically distributed databases feel like they’re right next to your application.

create

Create a new Hyperdrive configuration.
wrangler hyperdrive create <name> [options]
name
string
required
The name of the Hyperdrive configuration

Connection String Options

--connection-string
string
The connection string for the database you want Hyperdrive to connect to. Format: protocol://user:password@host:port/databaseSupported protocols: postgres, postgresql, mysql

Individual Parameter Options

Alternatively, configure the connection using individual parameters (conflicts with --connection-string):
--origin-host
string
The host of the origin database (alias: --host)
--origin-port
number
The port number of the origin database (alias: --port)
--origin-scheme
string
default:"postgresql"
The scheme used to connect to the origin database (alias: --scheme)Valid values: postgres, postgresql, mysql
--database
string
The name of the database within the origin database
--origin-user
string
The username used to connect to the origin database (alias: --user)
--origin-password
string
The password used to connect to the origin database (alias: --password)

Hyperdrive over Access Options

--access-client-id
string
The Client ID of the Access token to use when connecting to the origin database.Requires --access-client-secret. Conflicts with --origin-port.
--access-client-secret
string
The Client Secret of the Access token to use when connecting to the origin database

Caching Options

--caching-disabled
boolean
Disables the caching of SQL responses
--max-age
number
Specifies max duration for which items should persist in the cache. Cannot be set when caching is disabled
--swr
number
Indicates the number of seconds cache may serve the response after it becomes stale. Cannot be set when caching is disabled

Security Options

--ca-certificate-id
string
Sets custom CA certificate when connecting to origin database. Must be valid UUID of already uploaded CA certificate (alias: --ca-certificate-uuid)
--mtls-certificate-id
string
Sets custom mTLS client certificates when connecting to origin database. Must be valid UUID of already uploaded public/private key certificates (alias: --mtls-certificate-uuid)
--sslmode
string
Sets CA sslmode for connecting to database.Valid values: require, verify-ca, verify-full

Performance Options

--origin-connection-limit
number
The (soft) maximum number of connections that Hyperdrive may establish to the origin database

Worker Binding Options

--binding
string
The binding name of this resource in your Worker
--update-config
boolean
Automatically update your config file with the newly added resource

Examples

Using a connection string

wrangler hyperdrive create my-db --connection-string="postgresql://user:password@database.example.com:5432/mydb"

Using individual parameters

wrangler hyperdrive create my-db \
  --origin-host="database.example.com" \
  --origin-port=5432 \
  --database="mydb" \
  --origin-user="user" \
  --origin-password="password"

With caching options

wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --max-age=60 \
  --swr=15

With SSL/TLS options

wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --sslmode="verify-full" \
  --ca-certificate-id="abc123-def456-789"

delete

Delete a Hyperdrive configuration.
wrangler hyperdrive delete <id>
id
string
required
The ID of the Hyperdrive configuration to delete

Example

wrangler hyperdrive delete 01234567-89ab-cdef-0123-456789abcdef

list

List all Hyperdrive configurations.
wrangler hyperdrive list

Example

wrangler hyperdrive list
Displays a table with:
  • Configuration ID
  • Configuration name
  • Database user
  • Host
  • Port
  • Database scheme (PostgreSQL/MySQL)
  • Database name
  • Caching settings
  • mTLS configuration
  • Origin connection limit

get

Get details about a specific Hyperdrive configuration.
wrangler hyperdrive get <id>
id
string
required
The ID of the Hyperdrive configuration

Example

wrangler hyperdrive get 01234567-89ab-cdef-0123-456789abcdef
Returns the full configuration as JSON, including origin details, caching settings, and security configuration.

update

Update an existing Hyperdrive configuration.
wrangler hyperdrive update <id> [options]
id
string
required
The ID of the Hyperdrive configuration to update

Options

All options from the create command are supported, plus:
--name
string
Give your configuration a new name

Examples

Update connection credentials

wrangler hyperdrive update 01234567-89ab-cdef-0123-456789abcdef \
  --origin-user="newuser" \
  --origin-password="newpassword"

Update caching settings

wrangler hyperdrive update 01234567-89ab-cdef-0123-456789abcdef \
  --max-age=120 \
  --swr=30

Disable caching

wrangler hyperdrive update 01234567-89ab-cdef-0123-456789abcdef \
  --caching-disabled

Configuration

After creating a Hyperdrive configuration, add it to your Worker:
wrangler.json
{
  "hyperdrive": [
    {
      "binding": "HYPERDRIVE",
      "id": "01234567-89ab-cdef-0123-456789abcdef"
    }
  ]
}
Then use it in your Worker:
export default {
  async fetch(request, env) {
    // Connect to your database through Hyperdrive
    const client = await env.HYPERDRIVE.connect();
    
    try {
      // Execute queries
      const result = await client.query('SELECT * FROM users WHERE id = $1', [1]);
      return Response.json(result.rows);
    } finally {
      await client.end();
    }
  },
};

SSL/TLS Configuration

Hyperdrive supports three SSL modes for PostgreSQL:

require

Requires an SSL connection but does not verify the server certificate.
wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --sslmode="require"

verify-ca

Requires an SSL connection and verifies that the server certificate is issued by a trusted CA.
wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --sslmode="verify-ca" \
  --ca-certificate-id="abc123-def456"
When using verify-ca or verify-full, you must provide a CA certificate ID.

verify-full

Requires an SSL connection, verifies the CA, and verifies that the server hostname matches the certificate.
wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --sslmode="verify-full" \
  --ca-certificate-id="abc123-def456"

Mutual TLS (mTLS)

For databases requiring client certificate authentication:
wrangler hyperdrive create my-db \
  --connection-string="postgresql://user:password@database.example.com:5432/mydb" \
  --sslmode="verify-full" \
  --ca-certificate-id="abc123-def456" \
  --mtls-certificate-id="xyz789-uvw012"

Database Support

Hyperdrive supports:
  • PostgreSQL and PostgreSQL-compatible databases (e.g., CockroachDB, Neon, Supabase)
  • MySQL and MySQL-compatible databases (e.g., PlanetScale, Vitess)
Default ports:
  • PostgreSQL: 5432
  • MySQL: 3306

Build docs developers (and LLMs) love