Skip to content

Commit 29d3a9f

Browse files
authored
thomasgauvin: new overview for hyperdrive (#20374)
* thomasgauvin: new overview for hyperdrive * thomasgauvin: nits hyperdrive overview new
1 parent f8e0c56 commit 29d3a9f

File tree

1 file changed

+113
-25
lines changed

1 file changed

+113
-25
lines changed

src/content/docs/hyperdrive/index.mdx

Lines changed: 113 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,92 +8,180 @@ sidebar:
88
head:
99
- tag: title
1010
content: Hyperdrive
11-
1211
---
1312

14-
import { CardGrid, Description, Feature, LinkTitleCard, Plan, RelatedProduct } from "~/components"
13+
import {
14+
CardGrid,
15+
Description,
16+
Feature,
17+
LinkTitleCard,
18+
Plan,
19+
RelatedProduct,
20+
Tabs,
21+
TabItem,
22+
LinkButton
23+
} from "~/components";
1524

1625
<Description>
1726

18-
1927
Turn your existing regional database into a globally distributed database.
2028

21-
2229
</Description>
2330

2431
<Plan type="workers-paid" />
2532

26-
Hyperdrive is a service that accelerates queries you make to existing databases, making it faster to access your data from across the globe, irrespective of your users' location. Hyperdrive supports any Postgres database, including those hosted on AWS, Google Cloud and Neon, as well as Postgres-compatible databases like CockroachDB and Timescale, with MySQL coming soon.
33+
Hyperdrive is a service that accelerates queries you make to existing databases, making it faster to access your data from across the globe from [Cloudflare Workers](/workers/), irrespective of your users' location.
34+
35+
Hyperdrive supports any Postgres database, including those hosted on AWS, Google Cloud and Neon, as well as Postgres-compatible databases like CockroachDB and Timescale, with MySQL coming soon. You do not need to write new code or replace your favorite tools: Hyperdrive works with your existing code and tools you use.
36+
37+
Use Hyperdrive's connection string from your Cloudflare Workers application with your existing Postgres drivers and object-relational mapping (ORM) libraries:
38+
39+
<Tabs>
40+
<TabItem label="Workers Binding API">
41+
<Tabs>
42+
<TabItem label="index.ts">
43+
```ts
44+
import postgres from 'postgres';
45+
46+
export default {
47+
async fetch(request, env, ctx): Promise<Response> {
48+
// Hyperdrive provides a unique generated connection string to connect to
49+
// your database via Hyperdrive that can be used with your existing tools
50+
const sql = postgres(env.HYPERDRIVE.connectionString);
51+
52+
try {
53+
// Sample SQL query
54+
const results = await sql`SELECT * FROM pg_tables`;
55+
56+
// Close the client after the response is returned
57+
ctx.waitUntil(sql.end());
58+
59+
return Response.json(results);
60+
} catch (e) {
61+
return Response.json({ error: e instanceof Error ? e.message : e }, { status: 500 });
62+
}
63+
},
64+
} satisfies ExportedHandler<{ HYPERDRIVE: Hyperdrive }>;
65+
```
66+
67+
</TabItem>
68+
<TabItem label="wrangler.jsonc">
69+
```json
70+
{
71+
"$schema": "node_modules/wrangler/config-schema.json",
72+
"name": "WORKER-NAME",
73+
"main": "src/index.ts",
74+
"compatibility_date": "2025-02-04",
75+
"compatibility_flags": [
76+
"nodejs_compat"
77+
],
78+
"observability": {
79+
"enabled": true
80+
},
81+
"hyperdrive": [
82+
{
83+
"binding": "HYPERDRIVE",
84+
"id": "<YOUR_HYPERDRIVE_ID>",
85+
"localConnectionString": "<ENTER_LOCAL_CONNECTION_STRING_FOR_LOCAL_DEVELOPMENT_HERE>"
86+
}
87+
]
88+
}
89+
```
90+
91+
</TabItem>
92+
</Tabs>
93+
94+
<LinkButton href="/hyperdrive/get-started/">Get started</LinkButton>
95+
96+
</TabItem>
97+
</Tabs>
2798

28-
Use your existing Postgres drivers and object-relational mapping (ORM) libraries of your choice without any changes. Hyperdrive gives you a connection string that looks just like any other. You do not need to write new code or replace your favorite tools: Hyperdrive works with the ones you already use.
29-
30-
***
99+
---
31100

32101
## Features
33102

34103
<Feature header="Connect your database" href="/hyperdrive/get-started/" cta="Connect Hyperdrive to your database">
35104

36105
Connect Hyperdrive to your existing database and deploy a [Worker](/workers/) that queries it.
37106

38-
39107
</Feature>
40108

41109
<Feature header="PostgreSQL support" href="/hyperdrive/configuration/connect-to-postgres/" cta="Connect Hyperdrive to your PostgreSQL database">
42110

43111
Hyperdrive allows you to connect to any PostgreSQL or PostgreSQL-compatible database.
44112

45-
46113
</Feature>
47114

48115
<Feature header="Query Caching" href="/hyperdrive/configuration/query-caching/" cta="Learn about Query Caching">
49116

50117
Use Hyperdrive to cache the most popular queries executed against your database.
51118

52-
53119
</Feature>
54120

55-
***
121+
---
56122

57123
## Related products
58124

59125
<RelatedProduct header="Workers" href="/workers/" product="workers">
60126

61127
Build serverless applications and deploy instantly across the globe for exceptional performance, reliability, and scale.
62128

63-
64129
</RelatedProduct>
65130

66131
<RelatedProduct header="Pages" href="/pages/" product="pages">
67132

68133
Deploy dynamic front-end applications in record time.
69134

70-
71135
</RelatedProduct>
72136

73-
***
137+
---
74138

75139
## More resources
76140

77141
<CardGrid>
78142

79-
<LinkTitleCard title="Pricing" href="/hyperdrive/platform/pricing/" icon="seti:shell">
80-
Learn about Hyperdrive's pricing.
143+
<LinkTitleCard
144+
title="Pricing"
145+
href="/hyperdrive/platform/pricing/"
146+
icon="seti:shell"
147+
>
148+
Learn about Hyperdrive's pricing.
81149
</LinkTitleCard>
82150

83-
<LinkTitleCard title="Limits" href="/hyperdrive/platform/limits/" icon="document">
84-
Learn about Hyperdrive limits.
151+
<LinkTitleCard
152+
title="Limits"
153+
href="/hyperdrive/platform/limits/"
154+
icon="document"
155+
>
156+
Learn about Hyperdrive limits.
85157
</LinkTitleCard>
86158

87-
<LinkTitleCard title="Storage options" href="/workers/platform/storage-options/" icon="document">
88-
Learn more about the storage and database options you can build on with Workers.
159+
<LinkTitleCard
160+
title="Storage options"
161+
href="/workers/platform/storage-options/"
162+
icon="document"
163+
>
164+
Learn more about the storage and database options you can build on with
165+
Workers.
89166
</LinkTitleCard>
90167

91-
<LinkTitleCard title="Developer Discord" href="https://discord.cloudflare.com" icon="discord">
92-
Connect with the Workers community on Discord to ask questions, show what you are building, and discuss the platform with other developers.
168+
<LinkTitleCard
169+
title="Developer Discord"
170+
href="https://discord.cloudflare.com"
171+
icon="discord"
172+
>
173+
Connect with the Workers community on Discord to ask questions, show what you
174+
are building, and discuss the platform with other developers.
93175
</LinkTitleCard>
94176

95-
<LinkTitleCard title="@CloudflareDev" href="https://x.com/cloudflaredev" icon="x.com">
96-
Follow @CloudflareDev on Twitter to learn about product announcements, and what is new in Cloudflare Developer Platform.
177+
<LinkTitleCard
178+
title="@CloudflareDev"
179+
href="https://x.com/cloudflaredev"
180+
icon="x.com"
181+
>
182+
Follow @CloudflareDev on Twitter to learn about product announcements, and
183+
what is new in Cloudflare Developer Platform.
97184
</LinkTitleCard>
98185

99186
</CardGrid>
187+
````

0 commit comments

Comments
 (0)