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
Copy file name to clipboardExpand all lines: tidb-cloud/integrate-tidbcloud-with-vercel.md
+77-26Lines changed: 77 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ This guide describes how to connect your TiDB Cloud clusters to Vercel projects
18
18
19
19
For both of the preceding methods, TiDB Cloud provides the following options for programmatically connecting to your database:
20
20
21
-
-Direct connection: connect your TiDB Cloud cluster to your Vercel project directly using MySQL's standard connection system.
21
+
-Cluster: connect your TiDB Cloud cluster to your Vercel project with direct connections or [serverless driver](/tidb-cloud/serverless-driver.md).
22
22
-[Data App](/tidb-cloud/data-service-manage-data-app.md): access data of your TiDB Cloud cluster through a collection of HTTP endpoints.
23
23
24
24
## Prerequisites
@@ -48,7 +48,7 @@ You are expected to have an account and a cluster in TiDB Cloud. If you do not h
48
48
49
49
> **Note:**
50
50
>
51
-
> For TiDB Dedicated clusters, make sure that the traffic filter of the cluster allows all IP addresses (set to `0.0.0.0/0`) for connection, because Vercel deployments use [dynamic IP addresses](https://vercel.com/guides/how-to-allowlist-deployment-ip-address). If you use the TiDB Cloud Vercel integration, TiDB Cloud automatically adds a `0.0.0.0/0` traffic filter to your cluster in the integration workflow if there is none.
51
+
> For TiDB Dedicated clusters, make sure that the traffic filter of the cluster allows all IP addresses (set to `0.0.0.0/0`) for connection, because Vercel deployments use [dynamic IP addresses](https://vercel.com/guides/how-to-allowlist-deployment-ip-address).
52
52
53
53
To [integrate with Vercel via the TiDB Cloud Vercel Integration](#connect-via-the-tidb-cloud-vercel-integration), you are expected to be in the `Organization Owner` role of your organization or the `Project Owner` role of the target project in TiDB Cloud. For more information, see [User roles](/tidb-cloud/manage-user-access.md#user-roles).
54
54
@@ -69,10 +69,16 @@ One Vercel project can only connect to one TiDB Cloud Data App. To change the Da
69
69
70
70
To connect via the TiDB Cloud Vercel integration, go to the [TiDB Cloud integration](https://vercel.com/integrations/tidb-cloud) page from the [Vercel's Integrations Marketplace](https://vercel.com/integrations). Using this method, you can choose which cluster to connect to, and TiDB Cloud will automatically generate all the necessary environment variables for your Vercel projects.
71
71
72
+
> **Note:**
73
+
>
74
+
> This method is only available for TiDB Serverless clusters. If you want to connect to a TiDB Dedicated cluster, use the [manual method](#connect-via-manually-setting-environment-variables).
75
+
76
+
### Integration workflow
77
+
72
78
The detailed steps are as follows:
73
79
74
80
<SimpleTab>
75
-
<divlabel="Direct connection">
81
+
<divlabel="Cluster">
76
82
77
83
1. Click **Add Integration** in the upper-right area of the [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud) page. The **Add TiDB Cloud** dialog is displayed.
78
84
2. Select the scope of your integration in the drop-down list and click **Continue**.
@@ -84,8 +90,10 @@ The detailed steps are as follows:
84
90
2. Select your target TiDB Cloud organization and project.
85
91
3. Select **Cluster** as your connection type.
86
92
4. Select your target TiDB Cloud cluster. If the **Cluster** drop-down list is empty or you want to select a new TiDB Serverless cluster, click **+ Create Cluster** in the list to create one.
87
-
5. Select the framework that your Vercel projects are using. If the target framework is not listed, select **General**. Different frameworks determine different environment variables.
88
-
6. Click **Add Integration and Return to Vercel**.
93
+
5. Select the database that you want to connect to. If the **Database** drop-down list is empty or you want to select a new Database, click **+ Create Database** in the list to create one.
94
+
6. Select the framework that your Vercel projects are using. If the target framework is not listed, select **General**. Different frameworks determine different environment variables.
95
+
7. Choose whether to enable **Branching** to create new branches for preview environments.
96
+
8. Click **Add Integration and Return to Vercel**.
@@ -100,15 +108,16 @@ The detailed steps are as follows:
100
108
TIDB_PORT
101
109
TIDB_USER
102
110
TIDB_PASSWORD
111
+
TIDB_DATABASE
103
112
```
104
113
105
-
For TiDB Dedicated clusters, the root CA is setin this variable:
114
+
**Prisma**
106
115
107
116
```
108
-
TIDB_SSL_CA
117
+
DATABASE_URL
109
118
```
110
119
111
-
**Prisma**
120
+
**TiDB Cloud Serverless Driver**
112
121
113
122
```
114
123
DATABASE_URL
@@ -145,19 +154,74 @@ The detailed steps are as follows:
145
154
</div>
146
155
</SimpleTab>
147
156
157
+
### Configure connections
158
+
159
+
If you have installed [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud), you can add or remove connections inside the integration.
160
+
161
+
1. In your Vercel dashboard, click **Integrations**.
162
+
2. Click **Manage**in the TiDB Cloud entry.
163
+
3. Click **Configure**.
164
+
4. Click **Add Link** or **Remove** to add or remove connections.
When you remove a connection, the environment variables set by the integration workflow are removed from the Vercel project, too. However, this action does not affect the data of the TiDB Serverless cluster.
169
+
170
+
### Connect with TiDB Serverless branching
171
+
172
+
Vercel's [Preview Deployments](https://vercel.com/docs/deployments/preview-deployments) feature allows you to preview changes to your app in a live deployment without merging those changes to your Git project's production branch. With [TiDB Serverless Branching](/tidb-cloud/branch-overview.md), you can create a new instance foreach branch of your Vercel project. This allows you to preview app changesin a live deployment without affecting your production data.
173
+
174
+
>**Note:**
175
+
>
176
+
> Currently, TiDB Serverless branching only supports [Vercel projects associated with GitHub repositories](https://vercel.com/docs/deployments/git/vercel-for-github).
177
+
178
+
To enable TiDB Serverless Branching, you need to ensure the following in the [TiDB Cloud Vercel integration workflow](#integration-workflow):
179
+
180
+
1. Select **Cluster** as your connection type.
181
+
2. Enable **Branching** to create new branches for preview environments.
182
+
183
+
After you push changes to the Git repository, Vercel will trigger a preview deployment. TiDB Cloud integration will automatically create a TiDB Serverless branch for the Git branch and set environment variables. The detailed steps are as follows:
184
+
185
+
1. Create a new branch in your Git repository.
186
+
187
+
```shell
188
+
cd tidb-prisma-vercel-demo1
189
+
git checkout -b new-branch
190
+
```
191
+
192
+
2. Add some changes and push the changes to the remote repository.
193
+
3. Vercel will trigger a preview deployment for the new branch.
1. During the deployment, TiDB Cloud integration will automatically create a TiDB Serverless branch with the same name as the Git branch. If the TiDB Serverless branch already exists, TiDB Cloud integration will skip this step.
3. TiDB Cloud integration will also register a blocking check to waitfor the TiDB Serverless branch to be ready. You can rerun the check manually.
206
+
4. After the check is passed, you can visit the preview deployment to see the changes.
207
+
208
+
>**Note:**
209
+
>
210
+
> Due to a limitation of Vercel deployment workflow, the environment variable cannot be ensured to be setin the deployment. In this case, you need to redeploy the deployment.
211
+
212
+
>**Note:**
213
+
>
214
+
> For each organization in TiDB Cloud, you can create a maximum of five TiDB Serverless branches by default. To avoid exceeding the limit, you can delete the TiDB Serverless branches that are no longer needed. For more information, see [Manage TiDB Serverless branches](/tidb-cloud/branch-manage.md).
215
+
148
216
## Connect via manually setting environment variables
149
217
150
218
<SimpleTab>
151
-
<div label="Direct connection">
219
+
<div label="Cluster">
152
220
153
221
1. Get the connection information of your TiDB cluster.
154
222
155
223
You can get the connection information from the connection dialog of your cluster. To open the dialog, go to the [**Clusters**](https://tidbcloud.com/console/clusters) page of your project, click the name of your target cluster to go to its overview page, and then click **Connect**in the upper-right corner.
156
224
157
-
>**Note:**
158
-
>
159
-
> For TiDB Dedicated clusters, make sure that you have set the **Allow Access from Anywhere** traffic filter in this step.
160
-
161
225
2. Go to your Vercel dashboard > Vercel project >**Settings**>**Environment Variables**, and then [declare each environment variable value](https://vercel.com/docs/concepts/projects/environment-variables#declare-an-environment-variable) according to the connection information of your TiDB cluster.
@@ -200,16 +264,3 @@ You can get the information of `<User>`, `<Password>`, `<Endpoint>`, `<Port>`, a
200
264
201
265
</div>
202
266
</SimpleTab>
203
-
204
-
## Configure connections
205
-
206
-
If you have installed [TiDB Cloud Vercel integration](https://vercel.com/integrations/tidb-cloud), you can add or remove connections inside the integration.
207
-
208
-
1. In your Vercel dashboard, click **Integrations**.
209
-
2. Click **Manage** in the TiDB Cloud entry.
210
-
3. Click **Configure**.
211
-
4. Click **Add Link** or **Remove** to add or remove connections.
When you remove a connection, environment variables set by the integration workflow are removed from the Vercel project either. The traffic filter and the data of the TiDB Cloud cluster are not affected.
0 commit comments