# Cloudflare Hyperdrive

> How to use Reylo with Postgres or MySQL in a Cloudflare Worker through Hyperdrive. The drivers that work, the database the type check reads, and how soon a schema change shows.

Reylo on Postgres and MySQL through Hyperdrive

Reylo runs in a Worker on Postgres and MySQL through Hyperdrive, Cloudflare's connection pool. Everything on the [Postgres](https://reylo.dev/postgres) and [MySQL](https://reylo.dev/mysql) pages holds through it. Set up the Vite plugin as on [Cloudflare D1](https://reylo.dev/d1#setup).

| | |
| --- | --- |
| Postgres | `pg` or postgres.js, with the binding's connection string, and Drizzle over `pg` |
| MySQL | `mysql2` or `mariadb`, with the binding's `host`, `port`, `user`, `password` and `database` |
| The type check reads | Your development database, through [`direct_url`](https://reylo.dev/configuration#direct_url), never Hyperdrive |
| Node's APIs | `pg`, postgres.js, `mysql2` and `mariadb` need a compatibility date from 2026-08-04 on, or the `nodejs_compat` flag |

## Postgres

`worker.ts`:

```ts
import { Client } from "pg";
import getUser from "./get_user.sql";

export default {
  async fetch(request: Request, env: { HYPERDRIVE: Hyperdrive }, ctx: ExecutionContext) {
    const client = new Client({ connectionString: env.HYPERDRIVE.connectionString });
    await client.connect();
    const user = await getUser.run(client, { id: 1 });
    ctx.waitUntil(client.end());
    return Response.json(user);
  },
};
```

## MySQL

Hyperdrive refuses prepared statements, so Reylo runs `mysql2` there through `query()`, with each value written into the statement ([`mysql2`](https://reylo.dev/mysql#mysql2)). Reylo runs `mariadb` without prepared statements wherever it runs ([`mariadb`](https://reylo.dev/mysql#mariadb)).
