Before you begin
Before starting the tutorial, create a Vercel account and sign in.Step 1. Create a CockroachDB Standard cluster
- . If this is your first CockroachDB Cloud organization, it will be credited with $400 in to get you started.
- On the Get Started page, click Create cluster.
- On the Select a plan page, select Standard.
- On the Cloud & Regions page, select a cloud provider (GCP or AWS).
- In the Regions section, select a region for the cluster. Refer to for the regions where CockroachDB Standard clusters can be deployed. To create a multi-region cluster, click Add region and select additional regions.
- Click Next: Capacity.
- On the Capacity page, keep the at the default value of 2 vCPUs. Click Next: Finalize.
- On the Finalize page, name your cluster. If an active free trial is listed in the right pane, you will not need to add a payment method, though you will need to do this by the to maintain your organization’s clusters. Click Create cluster. Your cluster will be created in a few seconds and the Create SQL user dialog will display.
Step 2. Get the code
- Open the code repository’s GitHub repository.
-
Fork it by clicking Fork at the top. Netlify requires you to own a Netlify app’s repository.
- Set Owner to your GitHub identity or an organization.
- Disable Copy the master branch only.
- Click Fork.
- Copy the fork’s address, which you will use to clone it locally. Click Code, then in the Local tab, click SSH if you have added SSH keys to GitHub, or HTTPS if not. Click the copy symbol to copy the address.
-
Clone your fork locally. Replace with the full address of your fork, which will end with
prisma-examples.git.
- Use the browser
- Use the command line
Step 3. Create a Vercel project
- From the Vercel dashboard, click Add new… > Project.
-
Select the
prisma-examplesrepository you forked in Step 2 to import. - From the Framework preset dropdown, select Next.js.
- In the Root directory field, click Edit.
- Select the typescript > rest-nextjs-api-routes directory.
- Click Continue.
- Open the Build and Output Settings and toggle the build command’s Override switch to on.
-
Enter
yarn prisma db push && yarn next buildas the Build command. - Click Deploy. Your deployment will fail until you integrate CockroachDB in the next step, so you can leave this screen without waiting for it to finish.
Step 4. Integrate your project with CockroachDB
- Navigate to the CockroachDB page of Vercel’s integration marketplace.
- Click Add Integration.
- Select your Vercel account and click Continue.
- Select the project you just created and click Continue.
- Accept the permissions and click Add Integration.
- When prompted, log into CockroachDB Cloud and select the organization and cluster to integrate with.
-
Click Create to finish the integration.
After a few seconds, the window will close automatically and your Vercel project will have the
DATABASE_URLenvironment variable configured with the cluster’s connection string.
Step 5. Deploy the application
- Navigate to the Overview page for your Vercel project.
- Select the Deployments tab.
- Click Redeploy.
- Click Redeploy again from the pop-up dialog. Your project will be deployed in a few seconds. You can view the final product by clicking on the Domain link on your project’s Overview page.
See also
- Vercel’s official How to Build a Fullstack App with Next.js, Prisma, and PostgreSQL guide
- How to build a Complete Webapp with React, TypeScript & CockroachDB

