You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* update xata docs
* add documentation link
* Apply suggestions from code review
* Adding back the note component.
* Typo fix
---------
Co-authored-by: Jun Lee <[email protected]>
[Xata](https://xata.io) is a serverless data platform powered by PostgreSQL. Xata uniquely combines multiple types of stores (relational databases, search engines, analytics engines) into a single service, accessible through a consistent REST API.
8
+
[Xata](https://xata.io) is a PostgreSQL database platform designed to help developers operate and scale databases with enhanced productivity and performance. Xata provides features like instant copy-on-write database branches, zero-downtime schema changes, data anonymization, AI-powered performance monitoring, and BYOC.
9
+
9
10
10
11
:::note
11
12
12
-
You can connect to Xata using [Hyperdrive](/hyperdrive) (recommended), or using the Xata client, `@xata.io/client`. Both provide connection pooling and reduce the amount of round trips required to create a secure connection from Workers to your database.
13
+
You can connect to Xata using [Hyperdrive](/hyperdrive), which provides connection pooling and reduces the amount of round trips required to create a secure connection from Workers to your database.
13
14
14
15
Hyperdrive can provide lower latencies because it performs the database connection setup and connection pooling across Cloudflare's network. Hyperdrive supports native database drivers, libraries, and ORMs, and is included in all [Workers plans](/hyperdrive/platform/pricing/). Learn more about Hyperdrive in [How Hyperdrive Works](/hyperdrive/configuration/how-hyperdrive-works/).
15
16
16
17
:::
17
18
18
-
<Tabs>
19
-
<TabItemlabel="Hyperdrive (recommended)">
19
+
Refer to the full [Xata documentation](https://xata.io/documentation).
20
20
21
21
To connect to Xata using [Hyperdrive](/hyperdrive), follow these steps:
22
22
23
-
<Renderfile="xata-partial"product="hyperdrive"/>
24
-
</TabItem>
25
-
<TabItemlabel="Xata client">
26
-
27
-
## Set up an integration with Xata
28
-
29
-
To set up an integration with Xata:
30
-
31
-
1. You need to have an existing Xata database to connect to or create a new database from your Xata workspace [Create a Database](https://app.xata.io/workspaces).
32
-
33
-
2. In your database, you have several options for creating a table: you can start from scratch, use a template filled with sample data, or import data from a CSV file. For this guide, choose **Start with sample data**. This option automatically populates your database with two sample tables: `Posts` and `Users`.
34
-
35
-
3. Configure the Xata database credentials in your Worker:
36
-
37
-
You need to add your Xata database credentials as secrets to your Worker. First, get your database details from your [Xata Dashboard](https://app.xata.io), then add them as secrets using Wrangler:
38
-
39
-
```sh
40
-
# Add the Xata API key as a secret
41
-
npx wrangler secret put XATA_API_KEY
42
-
# When prompted, paste your Xata API key
43
-
44
-
# Add the Xata branch as a secret
45
-
npx wrangler secret put XATA_BRANCH
46
-
# When prompted, paste your Xata branch name (usually 'main')
47
-
48
-
# Add the Xata database URL as a secret
49
-
npx wrangler secret put XATA_DATABASE_URL
50
-
# When prompted, paste your Xata database URL
51
-
```
52
-
53
-
4. Install the [Xata CLI](https://xata.io/docs/getting-started/installation) and authenticate the CLI by running the following commands:
54
-
55
-
```sh
56
-
npm install -g @xata.io/cli
57
-
58
-
xata auth login
59
-
```
60
-
61
-
5. Once you have the CLI set up, In your Worker, run the following code in the root directory of your project:
62
-
63
-
```sh
64
-
xata init
65
-
```
66
-
67
-
Accept the default settings during the configuration process. After completion, a `.env` and `.xatarc` file will be generated in your project folder.
68
-
69
-
6. To enable Cloudflare access the secret values generated when running in development mode, create a `.dev.vars` file in your project's root directory and add the following content, replacing placeholders with the specific values:
70
-
71
-
```txt
72
-
XATA_API_KEY=<YOUR_API_KEY_HERE>
73
-
XATA_BRANCH=<YOUR_BRANCH_HERE>
74
-
XATA_DATABASE_URL=<YOUR_DATABASE_URL_HERE>
75
-
```
76
-
77
-
7. The following example shows how to make a query to your Xata database in a Worker. The credentials needed to connect to Xata have been added as secrets to your Worker.
0 commit comments