Skip to content

Commit 5249288

Browse files
committed
thomasgauvin: new overview for hyperdrive
1 parent d3c0017 commit 5249288

File tree

1 file changed

+111
-25
lines changed

1 file changed

+111
-25
lines changed

src/content/docs/hyperdrive/index.mdx

Lines changed: 111 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,92 +8,178 @@ 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+
} from "~/components";
1523

1624
<Description>
1725

18-
1926
Turn your existing regional database into a globally distributed database.
2027

21-
2228
</Description>
2329

2430
<Plan type="workers-paid" />
2531

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.
32+
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.
33+
34+
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.
35+
36+
Use Hyperdrive's connection string from your Cloudflare Workers application with your existing Postgres drivers and object-relational mapping (ORM) libraries:
37+
38+
<Tabs>
39+
<TabItem label="Workers Binding API">
40+
<Tabs>
41+
<TabItem label="index.ts">
42+
```ts
43+
import postgres from 'postgres';
44+
45+
export default {
46+
async fetch(request, env, ctx): Promise<Response> {
47+
// Hyperdrive provides a unique generated connection string to connect to
48+
// your database via Hyperdrive that can be used with your existing tools
49+
const sql = postgres(env.HYPERDRIVE.connectionString);
50+
51+
try {
52+
// Sample SQL query
53+
const results = await sql`SELECT * FROM pg_tables`;
54+
55+
// Close the client after the response is returned
56+
ctx.waitUntil(sql.end());
57+
58+
return Response.json(results);
59+
} catch (e) {
60+
return Response.json({ error: e instanceof Error ? e.message : e }, { status: 500 });
61+
}
62+
},
63+
} satisfies ExportedHandler<{ HYPERDRIVE: Hyperdrive }>;
64+
```
65+
</TabItem>
66+
<TabItem label="wrangler.jsonc">
67+
```jsonc
68+
{
69+
"$schema": "node_modules/wrangler/config-schema.json",
70+
"name": "WORKER-NAME",
71+
"main": "src/index.ts",
72+
"compatibility_date": "2025-02-04",
73+
"compatibility_flags": [
74+
"nodejs_compat"
75+
],
76+
"observability": {
77+
"enabled": true
78+
},
79+
"hyperdrive": [
80+
{
81+
"binding": "HYPERDRIVE",
82+
"id": "<YOUR_HYPERDRIVE_ID>",
83+
"localConnectionString": "<ENTER_LOCAL_CONNECTION_STRING_FOR_LOCAL_DEVELOPMENT_HERE>"
84+
}
85+
]
86+
}
87+
```
88+
89+
</TabItem>
90+
</Tabs>
91+
92+
Get started [using Hyperdrive from a Workers application](/hyperdrive/get-started/).
93+
94+
</TabItem>
95+
</Tabs>
2796

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-
***
97+
---
3198

3299
## Features
33100

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

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

38-
39105
</Feature>
40106

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

43109
Hyperdrive allows you to connect to any PostgreSQL or PostgreSQL-compatible database.
44110

45-
46111
</Feature>
47112

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

50115
Use Hyperdrive to cache the most popular queries executed against your database.
51116

52-
53117
</Feature>
54118

55-
***
119+
---
56120

57121
## Related products
58122

59123
<RelatedProduct header="Workers" href="/workers/" product="workers">
60124

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

63-
64127
</RelatedProduct>
65128

66129
<RelatedProduct header="Pages" href="/pages/" product="pages">
67130

68131
Deploy dynamic front-end applications in record time.
69132

70-
71133
</RelatedProduct>
72134

73-
***
135+
---
74136

75137
## More resources
76138

77139
<CardGrid>
78140

79-
<LinkTitleCard title="Pricing" href="/hyperdrive/platform/pricing/" icon="seti:shell">
80-
Learn about Hyperdrive's pricing.
141+
<LinkTitleCard
142+
title="Pricing"
143+
href="/hyperdrive/platform/pricing/"
144+
icon="seti:shell"
145+
>
146+
Learn about Hyperdrive's pricing.
81147
</LinkTitleCard>
82148

83-
<LinkTitleCard title="Limits" href="/hyperdrive/platform/limits/" icon="document">
84-
Learn about Hyperdrive limits.
149+
<LinkTitleCard
150+
title="Limits"
151+
href="/hyperdrive/platform/limits/"
152+
icon="document"
153+
>
154+
Learn about Hyperdrive limits.
85155
</LinkTitleCard>
86156

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.
157+
<LinkTitleCard
158+
title="Storage options"
159+
href="/workers/platform/storage-options/"
160+
icon="document"
161+
>
162+
Learn more about the storage and database options you can build on with
163+
Workers.
89164
</LinkTitleCard>
90165

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.
166+
<LinkTitleCard
167+
title="Developer Discord"
168+
href="https://discord.cloudflare.com"
169+
icon="discord"
170+
>
171+
Connect with the Workers community on Discord to ask questions, show what you
172+
are building, and discuss the platform with other developers.
93173
</LinkTitleCard>
94174

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.
175+
<LinkTitleCard
176+
title="@CloudflareDev"
177+
href="https://x.com/cloudflaredev"
178+
icon="x.com"
179+
>
180+
Follow @CloudflareDev on Twitter to learn about product announcements, and
181+
what is new in Cloudflare Developer Platform.
97182
</LinkTitleCard>
98183

99184
</CardGrid>
185+
````

0 commit comments

Comments
 (0)