Skip to content

Commit d8f1740

Browse files
nevikashahsdnts
authored andcommitted
update integrations docs (cloudflare#22966)
1 parent 6d69aa7 commit d8f1740

File tree

15 files changed

+174
-258
lines changed

15 files changed

+174
-258
lines changed

src/content/docs/workers/databases/connecting-to-databases.mdx

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,16 @@ Serverless databases provide HTTP-based proxies and drivers, also known as serve
4949

5050
By providing a way to query your database with HTTP, these serverless databases and drivers eliminate several roundtrips needed to establish a secure connection.
5151

52-
| Database | Integration | Library or Driver | Connection Method |
53-
| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------- |
54-
| [PlanetScale](https://planetscale.com/blog/introducing-the-planetscale-serverless-driver-for-javascript) | [Yes](/workers/databases/native-integrations/planetscale/) | [@planetscale/database](https://github.com/planetscale/database-js) | API via client library |
55-
| [Supabase](https://github.com/supabase/supabase/tree/master/examples/with-cloudflare-workers) | [Yes](/workers/databases/native-integrations/supabase/) | [@supabase/supabase-js](https://github.com/supabase/supabase-js) | API via client library |
56-
| [Prisma](https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-cloudflare-workers) | No | [prisma](https://github.com/prisma/prisma) | API via client library |
57-
| [Neon](https://blog.cloudflare.com/neon-postgres-database-from-workers/) | [Yes](/workers/databases/native-integrations/neon/) | [@neondatabase/serverless](https://neon.tech/blog/serverless-driver-for-postgres/) | API via client library |
58-
| [Hasura](https://hasura.io/blog/building-applications-with-cloudflare-workers-and-hasura-graphql-engine/) | No | API | GraphQL API via fetch() |
59-
| [Upstash Redis](https://blog.cloudflare.com/cloudflare-workers-database-integration-with-upstash/) | [Yes](/workers/databases/native-integrations/upstash/) | [@upstash/redis](https://github.com/upstash/upstash-redis) | API via client library |
60-
| [TiDB Cloud](https://docs.pingcap.com/tidbcloud/integrate-tidbcloud-with-cloudflare) | No | [@tidbcloud/serverless](https://github.com/tidbcloud/serverless-js) | API via client library |
52+
| Database | Library or Driver | Connection Method |
53+
| --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ----------------------- |
54+
| [PlanetScale](https://planetscale.com/blog/introducing-the-planetscale-serverless-driver-for-javascript) | [@planetscale/database](https://github.com/planetscale/database-js) | API via client library |
55+
| [Supabase](https://github.com/supabase/supabase/tree/master/examples/with-cloudflare-workers) | [@supabase/supabase-js](https://github.com/supabase/supabase-js) | API via client library |
56+
| [Prisma](https://www.prisma.io/docs/guides/deployment/deployment-guides/deploying-to-cloudflare-workers) | [prisma](https://github.com/prisma/prisma) | API via client library |
57+
| [Neon](https://blog.cloudflare.com/neon-postgres-database-from-workers/) | [@neondatabase/serverless](https://neon.tech/blog/serverless-driver-for-postgres/) | API via client library |
58+
| [Hasura](https://hasura.io/blog/building-applications-with-cloudflare-workers-and-hasura-graphql-engine/) | API | GraphQL API via fetch() |
59+
| [Upstash Redis](https://blog.cloudflare.com/cloudflare-workers-database-integration-with-upstash/) | [@upstash/redis](https://github.com/upstash/upstash-redis) | API via client library |
60+
| [TiDB Cloud](https://docs.pingcap.com/tidbcloud/integrate-tidbcloud-with-cloudflare) | [@tidbcloud/serverless](https://github.com/tidbcloud/serverless-js) | API via client library |
6161

62-
:::note[Easier setup with database integrations]
63-
64-
[Database Integrations](/workers/databases/native-integrations/) simplify the authentication for serverless database drivers by managing credentials on your behalf and includes support for PlanetScale, Neon and Supabase.
65-
66-
If you do not see an integration listed or have an integration to add, complete and submit the [Cloudflare Developer Platform Integration form](https://forms.gle/iaUqLWE8aezSEhgd6).
67-
68-
:::
6962

7063
Once you have installed the necessary packages, use the APIs provided by these packages to connect to your database and perform operations on it. Refer to detailed links for service-specific instructions.
7164

src/content/docs/workers/databases/native-integrations/index.mdx

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
pcx_content_type: navigation
3+
title: 3rd Party Integrations
4+
head: []
5+
description: Connect to third-party databases such as Supabase,
6+
Turso and PlanetScale)
7+
8+
---
9+
10+
import { DirectoryListing } from "~/components"
11+
12+
## Background
13+
14+
Connect to databases by configuring connection strings and credentials as [secrets](/workers/configuration/secrets/) in your Worker.
15+
16+
:::note[Making multiple round trip calls to a centralized database from a Worker?]
17+
18+
19+
If your Worker is making multiple round trip calls to a centralized database, your Worker may be a good fit for Smart Placement. Smart Placement speeds up applications by automatically running your Worker closer to your back-end infrastructure rather than the end user. Learn more about [how Smart Placement works](/workers/configuration/smart-placement/).
20+
:::
21+
22+
## Database credentials
23+
24+
When you rotate or update database credentials, you must update the corresponding [secrets](/workers/configuration/secrets/) in your Worker. Use the [`wrangler secret put`](/workers/wrangler/commands/#secret) command to update secrets securely or update the secret directly in the [Cloudflare dashboard](https://dash.cloudflare.com/?to=/:account/workers/services/view/:worker/production/settings).
25+
26+
## Database limits
27+
28+
You can connect to multiple databases by configuring separate sets of secrets for each database connection. Use descriptive secret names to distinguish between different database connections (for example, `DATABASE_URL_PROD` and `DATABASE_URL_STAGING`).
29+
30+
## Popular providers
31+
32+
<DirectoryListing />

src/content/docs/workers/databases/native-integrations/neon.mdx renamed to src/content/docs/workers/databases/third-party-integrations/neon.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { Render, PackageManagers } from "~/components";
77

88
[Neon](https://neon.tech/) is a fully managed serverless PostgreSQL. It separates storage and compute to offer modern developer features, such as serverless, branching, and bottomless storage.
99

10-
<Render file="database_integrations_definition" />
11-
1210
## Set up an integration with Neon
1311

1412
To set up an integration with Neon:
@@ -43,21 +41,23 @@ To set up an integration with Neon:
4341
(10, 'Neon', 10, 'Ne');
4442
```
4543

46-
4. Add the Neon database integration to your Worker:
44+
4. Configure the Neon database credentials in your Worker:
45+
46+
You need to add your Neon database connection string as a secret to your Worker. Get your connection string from the [Neon Console](https://console.neon.tech) under **Connection Details**, then add it as a secret using Wrangler:
4747

48-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
49-
2. In **Account Home**, select **Workers & Pages**.
50-
3. In **Overview**, select your Worker.
51-
4. Select **Integrations** > **Neon**.
52-
5. Follow the setup flow, selecting the database created in step 1.
48+
```sh
49+
# Add the database connection string as a secret
50+
npx wrangler secret put DATABASE_URL
51+
# When prompted, paste your Neon database connection string
52+
```
5353

5454
5. In your Worker, install the `@neondatabase/serverless` driver to connect to your database and start manipulating data:
5555

5656
<PackageManagers pkg="@neondatabase/serverless" />
5757

58-
6. The following example shows how to make a query to your Neon database in a Worker. The credentials needed to connect to Neon have been automatically added as secrets to your Worker through the integration.
58+
6. The following example shows how to make a query to your Neon database in a Worker. The credentials needed to connect to Neon have been added as secrets to your Worker.
5959

60-
```sql
60+
```js
6161
import { Client } from '@neondatabase/serverless';
6262

6363
export default {

src/content/docs/workers/databases/native-integrations/planetscale.mdx renamed to src/content/docs/workers/databases/third-party-integrations/planetscale.mdx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { Render, PackageManagers } from "~/components";
77

88
[PlanetScale](https://planetscale.com/) is a MySQL-compatible platform that makes databases infinitely scalable, easier and safer to manage.
99

10-
<Render file="database_integrations_definition" />
11-
1210
## Set up an integration with PlanetScale
1311

1412
To set up an integration with PlanetScale:
@@ -34,19 +32,29 @@ To set up an integration with PlanetScale:
3432
VALUES ('Ballpoint pen', 'https://example.com/500x500', '1');
3533
```
3634

37-
4. Add the PlanetScale integration to your Worker:
38-
39-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
40-
2. In **Account Home**, select **Workers & Pages**.
41-
3. In **Overview**, select your Worker.
42-
4. Select **Integrations** > **PlanetScale**.
43-
5. Follow the setup flow, selecting the database created in step 1.
35+
4. Configure the PlanetScale database credentials in your Worker:
36+
37+
You need to add your PlanetScale database credentials as secrets to your Worker. Get your connection details from the [PlanetScale Dashboard](https://app.planetscale.com) by creating a connection string, then add them as secrets using Wrangler:
38+
39+
```sh
40+
# Add the database host as a secret
41+
npx wrangler secret put DATABASE_HOST
42+
# When prompted, paste your PlanetScale host
43+
44+
# Add the database username as a secret
45+
npx wrangler secret put DATABASE_USERNAME
46+
# When prompted, paste your PlanetScale username
47+
48+
# Add the database password as a secret
49+
npx wrangler secret put DATABASE_PASSWORD
50+
# When prompted, paste your PlanetScale password
51+
```
4452

4553
5. In your Worker, install the `@planetscale/database` driver to connect to your PlanetScale database and start manipulating data:
4654

4755
<PackageManagers pkg="@planetscale/database" />
4856

49-
6. The following example shows how to make a query to your PlanetScale database in a Worker. The credentials needed to connect to PlanetScale have been automatically added as secrets to your Worker through the integration.
57+
6. The following example shows how to make a query to your PlanetScale database in a Worker. The credentials needed to connect to PlanetScale have been added as secrets to your Worker.
5058

5159
```js
5260
import { connect } from "@planetscale/database";

src/content/docs/workers/databases/native-integrations/supabase.mdx renamed to src/content/docs/workers/databases/third-party-integrations/supabase.mdx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { Render, PackageManagers } from "~/components";
77

88
[Supabase](https://supabase.com/) is an open source Firebase alternative and a PostgreSQL database service that offers real-time functionality, database backups, and extensions. With Supabase, developers can quickly set up a PostgreSQL database and build applications.
99

10-
<Render file="database_integrations_definition" />
11-
1210
## Set up an integration with Supabase
1311

1412
To set up an integration with Supabase:
@@ -35,21 +33,27 @@ To set up an integration with Supabase:
3533
INSERT INTO countries (name) VALUES ('The Netherlands');
3634
```
3735

38-
4. Add the Supabase database integration to your Worker:
36+
4. Configure the Supabase database credentials in your Worker:
37+
38+
You need to add your Supabase URL and anon key as secrets to your Worker. Get these from your [Supabase Dashboard](https://supabase.com/dashboard) under **Settings** > **API**, then add them as secrets using Wrangler:
3939

40-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
41-
2. In **Account Home**, select **Workers & Pages**.
42-
3. In **Overview**, select your Worker.
43-
4. Select **Integrations** > **Supabase**.
44-
5. Follow the setup flow, selecting the database created in step 1.
40+
```sh
41+
# Add the Supabase URL as a secret
42+
npx wrangler secret put SUPABASE_URL
43+
# When prompted, paste your Supabase project URL
44+
45+
# Add the Supabase anon key as a secret
46+
npx wrangler secret put SUPABASE_KEY
47+
# When prompted, paste your Supabase anon/public key
48+
```
4549

4650
5. In your Worker, install the `@supabase/supabase-js` driver to connect to your database and start manipulating data:
4751

4852
<PackageManagers pkg="@supabase/supabase-js" />
4953

50-
6. The following example shows how to make a query to your Supabase database in a Worker. The credentials needed to connect to Supabase have been automatically added as secrets to your Worker through the integration.
54+
6. The following example shows how to make a query to your Supabase database in a Worker. The credentials needed to connect to Supabase have been added as secrets to your Worker.
5155

52-
```sql
56+
```js
5357
import { createClient } from '@supabase/supabase-js';
5458

5559
export default {

src/content/docs/workers/databases/native-integrations/turso.mdx renamed to src/content/docs/workers/databases/third-party-integrations/turso.mdx

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { Render, PackageManagers } from "~/components";
77

88
[Turso](https://turso.tech/) is an edge-hosted, distributed database based on [libSQL](https://libsql.org/), an open-source fork of SQLite. Turso was designed to minimize query latency for applications where queries comes from anywhere in the world.
99

10-
<Render file="database_integrations_definition" />
11-
1210
## Set up an integration with Turso
1311

1412
To set up an integration with Turso:
@@ -84,19 +82,35 @@ To set up an integration with Turso:
8482
(10, 'Neon', 10, 'Ne');
8583
```
8684

87-
4. Add the Turso database integration to your Worker:
85+
4. Configure the Turso database credentials in your Worker:
86+
87+
You need to add your Turso database URL and authentication token as secrets to your Worker. First, get your database URL and create an authentication token:
88+
89+
```sh
90+
# Get your database URL
91+
turso db show my-db --url
92+
93+
# Create an authentication token
94+
turso db tokens create my-db
95+
```
96+
97+
Then add these as secrets to your Worker using Wrangler:
8898

89-
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com) and select your account.
90-
2. In **Account Home**, select **Workers & Pages**.
91-
3. In **Overview**, select your Worker.
92-
4. Select **Integrations** > **Turso**.
93-
5. Follow the setup flow, selecting the database created in step 1.
99+
```sh
100+
# Add the database URL as a secret
101+
npx wrangler secret put TURSO_URL
102+
# When prompted, paste your database URL
103+
104+
# Add the authentication token as a secret
105+
npx wrangler secret put TURSO_AUTH_TOKEN
106+
# When prompted, paste your authentication token
107+
```
94108

95109
5. In your Worker, install the Turso client library:
96110

97111
<PackageManagers pkg="@libsql/client" />
98112

99-
6. The following example shows how to make a query to your Turso database in a Worker. The credentials needed to connect to Turso have been automatically added as [secrets](/workers/configuration/secrets/) to your Worker through the integration.
113+
6. The following example shows how to make a query to your Turso database in a Worker. The credentials needed to connect to Turso have been added as [secrets](/workers/configuration/secrets/) to your Worker.
100114

101115
```ts
102116
import { Client as LibsqlClient, createClient } from "@libsql/client/web";

0 commit comments

Comments
 (0)