Help us improve
Share bugs, ideas, or general feedback.
Configures Cloudflare Hyperdrive for Workers-to-PostgreSQL/MySQL connections with global pooling, query caching, and low latency. Use for pool exhaustion, TLS errors, or Drizzle/Prisma in Workers.
npx claudepluginhub secondsky/claude-skills --plugin cloudflare-hyperdriveHow this skill is triggered — by the user, by Claude, or both
Slash command
/cloudflare-hyperdrive:cloudflare-hyperdriveThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Status**: Production Ready ✅ | **Last Verified**: 2025-11-18
references/connection-pooling.mdreferences/drizzle-integration.mdreferences/prisma-integration.mdreferences/query-caching.mdreferences/setup-guide.mdreferences/supported-databases.mdreferences/tls-ssl-setup.mdreferences/troubleshooting.mdreferences/wrangler-commands.mdscripts/check-versions.shtemplates/drizzle-mysql.tstemplates/drizzle-postgres.tstemplates/local-dev-setup.shtemplates/mysql2-basic.tstemplates/postgres-basic.tstemplates/postgres-js.tstemplates/postgres-pool.tstemplates/prisma-postgres.tstemplates/wrangler-hyperdrive-config.jsoncSets up Neon and Vercel serverless Postgres for edge/serverless environments like Cloudflare Workers, Vercel Edge, Next.js. Enables HTTP/WebSocket queries, Drizzle/Prisma ORM integration, database branching, migrations, PITR, and fixes connection pool/SSL errors.
Guides Cloudflare D1 serverless SQLite usage: databases, migrations, bindings, queries, read replicas, Sessions API, and fixes D1_ERROR, statement too long errors.
Provides patterns for Neon serverless Postgres: branching, connection pooling, Prisma/Drizzle integrations with pooled/direct URLs and serverless drivers.
Share bugs, ideas, or general feedback.
Status: Production Ready ✅ | Last Verified: 2025-11-18
Connect Workers to existing PostgreSQL/MySQL databases:
bunx wrangler hyperdrive create my-db \
--connection-string="postgres://user:pass@host:5432/database"
Save the id!
{
"name": "my-worker",
"main": "src/index.ts",
"compatibility_date": "2024-09-23",
"compatibility_flags": ["nodejs_compat"], // REQUIRED!
"hyperdrive": [
{
"binding": "HYPERDRIVE",
"id": "<ID_FROM_STEP_1>"
}
]
}
bun add pg # or postgres, or mysql2
import { Client } from 'pg';
export default {
async fetch(request, env, ctx) {
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const result = await client.query('SELECT * FROM users LIMIT 10');
await client.end();
return Response.json(result.rows);
}
};
Load references/setup-guide.md for complete walkthrough.
import { Client } from 'pg';
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const result = await client.query('SELECT * FROM users');
await client.end();
import postgres from 'postgres';
const sql = postgres(env.HYPERDRIVE.connectionString);
const users = await sql`SELECT * FROM users`;
import mysql from 'mysql2/promise';
const connection = await mysql.createConnection(env.HYPERDRIVE.connectionString);
const [rows] = await connection.execute('SELECT * FROM users');
await connection.end();
import { drizzle } from 'drizzle-orm/node-postgres';
import { Client } from 'pg';
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const db = drizzle(client);
const users = await db.select().from(usersTable);
await client.end();
export default {
async fetch(request, env, ctx) {
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const users = await client.query('SELECT * FROM users WHERE active = true');
await client.end();
return Response.json(users.rows);
}
};
const userId = new URL(request.url).searchParams.get('id');
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
const result = await client.query(
'SELECT * FROM users WHERE id = $1',
[userId]
);
await client.end();
const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
await client.connect();
try {
await client.query('BEGIN');
await client.query('UPDATE accounts SET balance = balance - 100 WHERE id = $1', [1]);
await client.query('UPDATE accounts SET balance = balance + 100 WHERE id = $1', [2]);
await client.query('COMMIT');
} catch (e) {
await client.query('ROLLBACK');
throw e;
} finally {
await client.end();
}
PostgreSQL:
MySQL:
References (references/):
setup-guide.md - Complete setup walkthrough (create config, bind, query)connection-pooling.md - Connection pool configuration and best practicesquery-caching.md - Query caching strategies and optimizationdrizzle-integration.md - Drizzle ORM integration patternsprisma-integration.md - Prisma ORM integration patternssupported-databases.md - Complete list of supported PostgreSQL and MySQL providerstls-ssl-setup.md - TLS/SSL configuration for secure connectionstroubleshooting.md - Common issues and solutionswrangler-commands.md - Complete wrangler CLI commands for HyperdriveTemplates (templates/):
postgres-basic.ts - Basic PostgreSQL with node-postgrespostgres-js.ts - PostgreSQL with postgres.js driverpostgres-pool.ts - PostgreSQL with connection poolingmysql2-basic.ts - MySQL with mysql2 driverdrizzle-postgres.ts - Drizzle ORM with PostgreSQLdrizzle-mysql.ts - Drizzle ORM with MySQLprisma-postgres.ts - Prisma ORM with PostgreSQLlocal-dev-setup.sh - Local development setup scriptwrangler-hyperdrive-config.jsonc - Wrangler configuration exampleQuestions? Issues?
references/setup-guide.md for complete setup