sellStorage & Databases
rocket_launch

Hyperdrive

Keep your current database — Hyperdrive makes it feel global and instant.

2Engines: Postgres & MySQL
PoolingConnection reuse
CachingOn by default
FreeAvailable on Free plan
lightbulb

What is Hyperdrive?

Hyperdrive is an accelerator that sits in front of a database you already have (like PostgreSQL or MySQL) and makes querying it from Cloudflare Workers fast — no matter where in the world the request comes from.

Normally a regional database (one that lives in a single data center) is slow to reach from far away, and opening a fresh connection for every request adds delay. Hyperdrive fixes both with connection pooling and query caching.

fast_forward

Think of it like…

A VIP fast lane to your database. Instead of dialing the database from scratch every time (slow handshakes), Hyperdrive keeps warm lines open and remembers recent answers — so most requests skip the wait.

help

Why use Hyperdrive?

Workers run all over the globe, but your database lives in one place. Without help, every query pays a long round-trip and a connection setup cost. Hyperdrive removes that pain so your existing SQL database performs like it was built for the edge.

hub

Connection pooling

Reuses a pool of warm database connections instead of opening one per request.

bolt

Query caching

Caches results of popular read queries so repeats return almost instantly.

move_up

No migration

Keep your current Postgres/MySQL provider; just point Workers through Hyperdrive.

public

Feels global

Far-away Workers query a single regional database without the usual lag.

target

When should you use it?

storage

You already have a SQL DB

An existing Postgres or MySQL on AWS, Neon, PlanetScale, etc. that you want to keep.

travel_explore

Global users, one DB

Visitors worldwide but a single regional database that feels slow far away.

sync_problem

Connection limits hit

Serverless functions exhaust your database's connection limit — pooling fixes that.

menu_book

Read-heavy queries

The same SELECTs repeat often, so caching delivers a big speed-up.

rocket_launch

How do you start?

Give Hyperdrive your database connection string (a connection string = the single URL with host, user, password, and database name). Then bind it and connect using a normal Postgres driver from your Worker.

  1. Create a Hyperdrive config

    Point it at your existing database with its connection string. Wrangler prints an id.

    bash
    npx wrangler hyperdrive create my-db-config \
      --connection-string="postgres://user:password@db-host.example.com:5432/mydb"
  2. Bind it to your Worker

    Add the id to wrangler.jsonc under the HYPERDRIVE binding.

    json
    {
      "hyperdrive": [
        {
          "binding": "HYPERDRIVE",
          "id": "<paste-your-id-here>"
        }
      ]
    }
  3. Install a Postgres driver

    Use the popular pg package (add its TypeScript types too).

    bash
    npm i pg
    npm i -D @types/pg
  4. Query through Hyperdrive

    Read env.HYPERDRIVE.connectionString and connect as usual — Hyperdrive handles pooling and caching for you.

    js
    import { Client } from "pg";
    
    export default {
      async fetch(request, env, ctx) {
        const client = new Client({
          connectionString: env.HYPERDRIVE.connectionString,
        });
        await client.connect();
    
        const { rows } = await client.query("SELECT * FROM products LIMIT 10");
        ctx.waitUntil(client.end());
        return Response.json(rows);
      },
    };
  5. Deploy

    Publish your Worker and queries now flow through the fast lane.

    bash
    npx wrangler deploy
school

Key concepts

link

Connection string

The single URL with host, port, user, password, and database name that locates your DB.

pool

Connection pool

A set of ready-made connections kept warm and shared across requests to avoid setup cost.

cached

Query cache

Recent read-query results are remembered so identical repeats skip the database.

verified

Your DB stays the source

Hyperdrive only accelerates access; your real data still lives in your own database.

tips_and_updates

Tips & notes

tune

Tune caching for fresh data

Query caching is on by default and is great for data that does not change every second. If a query must always return the very latest value, you can disable caching for it.

  • Hyperdrive is available on both Free and Paid plans, so you can try it at no cost.
  • It supports PostgreSQL (and compatibles like Neon, CockroachDB, Timescale) and MySQL.
  • Use ctx.waitUntil(client.end()) so closing the connection does not delay your response.
  • Need a Cloudflare-native SQL database instead? Look at D1.