Skip to content

Commit ee5f6ce

Browse files
authored
thomasgauvin: make node-postgres recommendation more prevalent (#26419)
1 parent e099bc0 commit ee5f6ce

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

src/content/docs/hyperdrive/examples/connect-to-postgres/index.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
32
hideChildren: false
43
pcx_content_type: concept
54
title: Connect to PostgreSQL
@@ -44,7 +43,7 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/#
4443

4544
| Driver | Documentation | Minimum Version Required | Notes |
4645
| ---------------------------------------------------------- | ------------------------------------------------------------------------ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
47-
| node-postgres - `pg` (recommended) | [node-postgres - `pg` documentation](https://node-postgres.com/) | `[email protected]` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires `compatibility_flags = ["nodejs_compat"]` and `compatibility_date = "2024-09-23"` - refer to [Node.js compatibility](/workers/runtime-apis/nodejs). Requires wrangler `3.78.7` or later. |
46+
| node-postgres - `pg` (recommended) | [node-postgres - `pg` documentation](https://node-postgres.com/) | `[email protected]` | `8.11.4` introduced a bug with URL parsing and will not work. `8.11.5` fixes this. Requires `compatibility_flags = ["nodejs_compat"]` and `compatibility_date = "2024-09-23"` - refer to [Node.js compatibility](/workers/runtime-apis/nodejs). Requires wrangler `3.78.7` or later. |
4847
| Postgres.js | [Postgres.js documentation](https://github.com/porsager/postgres) | `[email protected]` | Supported in both Workers & Pages. |
4948
| Drizzle | [Drizzle documentation](https://orm.drizzle.team/) | `0.26.2`^ | |
5049
| Kysely | [Kysely documentation](https://kysely.dev/) | `0.26.3`^ | |
@@ -54,6 +53,8 @@ Hyperdrive uses Workers [TCP socket support](/workers/runtime-apis/tcp-sockets/#
5453

5554
Other drivers and ORMs not listed may also be supported: this list is not exhaustive.
5655

56+
<Render file="node-postgres-recommendation" product="hyperdrive" />
57+
5758
### Database drivers and Node.js compatibility
5859

5960
[Node.js compatibility](/workers/runtime-apis/nodejs/) is required for database drivers, including Postgres.js, and needs to be configured for your Workers project.

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/node-postgres.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ import { Render } from "~/components";
1111

1212
[node-postgres](https://node-postgres.com/) (pg) is a widely-used PostgreSQL driver for Node.js applications. This example demonstrates how to use node-postgres with Cloudflare Hyperdrive in a Workers application.
1313

14+
<Render file="node-postgres-recommendation" product="hyperdrive" />
15+
1416
<Render file="use-node-postgres-to-make-query" product="hyperdrive" />

src/content/docs/hyperdrive/examples/connect-to-postgres/postgres-drivers-and-libraries/postgres-js.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@ import { Render } from "~/components";
1111

1212
[Postgres.js](https://github.com/porsager/postgres) is a modern, fully-featured PostgreSQL driver for Node.js. This example demonstrates how to use Postgres.js with Cloudflare Hyperdrive in a Workers application.
1313

14+
<Render file="node-postgres-recommendation" product="hyperdrive" />
15+
1416
<Render file="use-postgres-js-to-make-query" product="hyperdrive" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
{}
3+
---
4+
5+
:::note[Recommended driver]
6+
7+
[Node-postgres](https://node-postgres.com/) (`pg`) is the recommended driver for connecting to your Postgres database from JavaScript or TypeScript Workers. It has the best compatibility with Hyperdrive's caching and is commonly available with popular ORM libraries. [Postgres.js](https://github.com/porsager/postgres) is also supported.
8+
9+
:::

0 commit comments

Comments
 (0)