cloudflare-hyperdrive
Complete knowledge domain for Cloudflare Hyperdrive - connecting Cloudflare Workers to existing PostgreSQL and MySQL databases with global connection pooling, query caching, and reduced latency. Use when: connecting Workers to existing databases, migrating PostgreSQL/MySQL to Cloudflare, setting up connection pooling, configuring Hyperdrive bindings, using node-postgres/postgres.js/mysql2 drivers, integrating Drizzle ORM or Prisma ORM, or encountering "Failed to acquire a connection from the pool", "TLS not supported by the database", "connection refused", "nodejs_compat missing", "Code generation from strings disallowed", or Hyperdrive configuration errors. Keywords: hyperdrive, cloudflare hyperdrive, workers hyperdrive, postgres workers, mysql workers, connection pooling, query caching, node-postgres, pg, postgres.js, mysql2, drizzle hyperdrive, prisma hyperdrive, workers rds, workers aurora, workers neon, workers supabase, database acceleration, hybrid architecture, cloudflare tunnel database, wrangler hyperdrive, hyperdrive bindings, local development hyperdrive
What this skill does
# Cloudflare Hyperdrive **Status**: Production Ready ✅ **Last Updated**: 2025-10-22 **Dependencies**: cloudflare-worker-base (recommended for Worker setup) **Latest Versions**: [email protected]+, [email protected]+, [email protected]+, [email protected]+ --- ## Quick Start (5 Minutes) ### 1. Create Hyperdrive Configuration ```bash # For PostgreSQL npx wrangler hyperdrive create my-postgres-db \ --connection-string="postgres://user:[email protected]:5432/database" # For MySQL npx wrangler hyperdrive create my-mysql-db \ --connection-string="mysql://user:[email protected]:3306/database" # Output: # ✅ Successfully created Hyperdrive configuration # # [[hyperdrive]] # binding = "HYPERDRIVE" # id = "a76a99bc-7901-48c9-9c15-c4b11b559606" ``` **Save the `id` value** - you'll need it in the next step! --- ### 2. Configure Bindings in wrangler.jsonc Add to your `wrangler.jsonc`: ```jsonc { "name": "my-worker", "main": "src/index.ts", "compatibility_date": "2024-09-23", "compatibility_flags": ["nodejs_compat"], // REQUIRED for database drivers "hyperdrive": [ { "binding": "HYPERDRIVE", // Available as env.HYPERDRIVE "id": "a76a99bc-7901-48c9-9c15-c4b11b559606" // From wrangler hyperdrive create } ] } ``` **CRITICAL:** - `nodejs_compat` flag is **REQUIRED** for all database drivers - `binding` is how you access Hyperdrive in code (`env.HYPERDRIVE`) - `id` is the Hyperdrive configuration ID (NOT your database ID) --- ### 3. Install Database Driver ```bash # For PostgreSQL (choose one) npm install pg # node-postgres (most common) npm install postgres # postgres.js (modern, minimum v3.4.5) # For MySQL npm install mysql2 # mysql2 (minimum v3.13.0) ``` --- ### 4. Query Your Database **PostgreSQL with node-postgres (pg):** ```typescript import { Client } from "pg"; type Bindings = { HYPERDRIVE: Hyperdrive; }; export default { async fetch(request: Request, env: Bindings, ctx: ExecutionContext) { const client = new Client({ connectionString: env.HYPERDRIVE.connectionString }); await client.connect(); try { const result = await client.query('SELECT * FROM users LIMIT 10'); return Response.json({ users: result.rows }); } finally { // Clean up connection AFTER response is sent ctx.waitUntil(client.end()); } } }; ``` **MySQL with mysql2:** ```typescript import { createConnection } from "mysql2/promise"; export default { async fetch(request: Request, env: Bindings, ctx: ExecutionContext) { const connection = await createConnection({ host: env.HYPERDRIVE.host, user: env.HYPERDRIVE.user, password: env.HYPERDRIVE.password, database: env.HYPERDRIVE.database, port: env.HYPERDRIVE.port, disableEval: true // REQUIRED for Workers (eval() not supported) }); try { const [rows] = await connection.query('SELECT * FROM users LIMIT 10'); return Response.json({ users: rows }); } finally { ctx.waitUntil(connection.end()); } } }; ``` --- ### 5. Deploy ```bash npx wrangler deploy ``` **That's it!** Your Worker now connects to your existing database via Hyperdrive with: - ✅ Global connection pooling - ✅ Automatic query caching - ✅ Reduced latency (eliminates 7 round trips) --- ## How Hyperdrive Works ### The Problem Connecting to traditional databases from Cloudflare's 300+ global locations presents challenges: 1. **High Latency** - Multiple round trips for each connection: - TCP handshake (1 round trip) - TLS negotiation (3 round trips) - Database authentication (3 round trips) - **Total: 7 round trips before you can even send a query** 2. **Connection Limits** - Traditional databases handle limited concurrent connections, easily exhausted by distributed traffic ### The Solution Hyperdrive solves these problems by: 1. **Edge Connection Setup** - Connection handshake happens near your Worker (low latency) 2. **Connection Pooling** - Pool near your database reuses connections (eliminates round trips) 3. **Query Caching** - Popular queries cached at the edge (reduces database load) **Result**: Single-region databases feel globally distributed. --- ## Complete Setup Process ### Step 1: Prerequisites **You need:** - Cloudflare account with Workers access - Existing PostgreSQL (v9.0-17.x) or MySQL (v5.7-8.x) database - Database accessible via: - **Public internet** (with TLS/SSL enabled), OR - **Private network** (via Cloudflare Tunnel) **Important**: Hyperdrive **requires TLS/SSL**. Ensure your database has encryption enabled. --- ### Step 2: Create Hyperdrive Configuration **Option A: Wrangler CLI** (Recommended) ```bash # PostgreSQL connection string format: # postgres://username:password@hostname:port/database_name npx wrangler hyperdrive create my-hyperdrive \ --connection-string="postgres://myuser:[email protected]:5432/mydb" # MySQL connection string format: # mysql://username:password@hostname:port/database_name npx wrangler hyperdrive create my-hyperdrive \ --connection-string="mysql://myuser:[email protected]:3306/mydb" ``` **Option B: Cloudflare Dashboard** 1. Go to [Hyperdrive Dashboard](https://dash.cloudflare.com/?to=/:account/workers/hyperdrive) 2. Click **Create Configuration** 3. Enter connection details: - Name: `my-hyperdrive` - Protocol: PostgreSQL or MySQL - Host: `db.example.com` - Port: `5432` (PostgreSQL) or `3306` (MySQL) - Database: `mydb` - Username: `myuser` - Password: `mypassword` 4. Click **Create** **Connection String Formats:** ```bash # PostgreSQL (standard) postgres://user:password@host:5432/database # PostgreSQL with SSL mode postgres://user:password@host:5432/database?sslmode=require # MySQL mysql://user:password@host:3306/database # With special characters in password (URL encode) postgres://user:p%40ssw%24rd@host:5432/database # p@ssw$rd ``` --- ### Step 3: Configure Worker Bindings Add Hyperdrive binding to `wrangler.jsonc`: ```jsonc { "name": "my-worker", "main": "src/index.ts", "compatibility_date": "2024-09-23", "compatibility_flags": ["nodejs_compat"], "hyperdrive": [ { "binding": "HYPERDRIVE", "id": "<your-hyperdrive-id-here>" } ] } ``` **Multiple Hyperdrive configs:** ```jsonc { "hyperdrive": [ { "binding": "POSTGRES_DB", "id": "postgres-hyperdrive-id" }, { "binding": "MYSQL_DB", "id": "mysql-hyperdrive-id" } ] } ``` **Access in Worker:** ```typescript type Bindings = { POSTGRES_DB: Hyperdrive; MYSQL_DB: Hyperdrive; }; export default { async fetch(request, env: Bindings, ctx) { // Access different databases const pgClient = new Client({ connectionString: env.POSTGRES_DB.connectionString }); const mysqlConn = await createConnection({ host: env.MYSQL_DB.host, ... }); } }; ``` --- ### Step 4: Install Database Driver **PostgreSQL Drivers:** ```bash # Option 1: node-postgres (pg) - Most popular npm install pg npm install @types/pg # TypeScript types # Option 2: postgres.js - Modern, faster (minimum v3.4.5) npm install postgres@^3.4.5 ``` **MySQL Drivers:** ```bash # mysql2 (minimum v3.13.0) npm install mysql2 ``` **Driver Comparison:** | Driver | Database | Pros | Cons | Min Version | |--------|----------|------|------|-------------| | **pg** | PostgreSQL | Most popular, stable, well-documented | Slightly slower than postgres.js | 8.13.0+ | | **postgres** | PostgreSQL | Faster, modern API, streaming support | Newer (less community examples) | 3.4.5+ | | **mysql2** | MySQL | Promises, prepared statements, fast | Requires `disableEval: true` for Workers | 3.13.0+ | --- ### Step 5: Use Driver in Worker **PostgreSQL with pg (Client):** ```typescript import { Client } from "pg"; export default { async fetch(request: Request, env: { HYPERDRIVE: Hyperdrive }, ctx: ExecutionContext) { // Create client for this request
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.