Skip to main content
This tutorial shows you how to use Vercel to deploy a web application built with Next.js, Express, Prisma, and CockroachDB Standard.

Before you begin

Before starting the tutorial, do the following:
  1. Create a CockroachDB Cloud account.
  2. Create a Vercel account.

Step 1. Get the code

  1. Create a GitHub account if you haven’t already.
  2. In GitHub, create your own fork of CockroachDB’s prisma-examples repo.

Step 2. Create a Vercel project

  1. From the Vercel dashboard, click Add new… > Project.
  2. Select the prisma-examples repository you forked in Step 1 to import.
  3. From the Framework preset dropdown, select Next.js.
  4. In the Root directory field, click Edit.
  5. Select the typescript > rest-nextjs-api-routes directory.
  6. Click Continue.
  7. Open the Build and Output Settings and toggle the build command’s Override switch to on.
  8. Enter yarn prisma db push && yarn next build as the Build command.
  9. 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 3. Integrate CockroachDB

  1. Navigate to the CockroachDB page of Vercel’s integration marketplace.
  2. Click Add Integration.
  3. Select your Vercel account and click Continue.
  4. Select the project you just created and click Continue.
  5. Accept the permissions and click Add Integration. A window will pop up prompting you to log in to CockroachDB Cloud if you haven’t already.
  6. In the CockroachDB Cloud pop-up window, select the organization in which you want to create a new CockroachDB Standard cluster.
  7. Click Create. After a few seconds, your cluster will be created and the pop-up window will close automatically. Once this is done, your Vercel project will have the DATABASE_URL environment variable automatically populated with the connection string for your new cluster.

Step 3. Deploy the application

  1. Navigate to the Overview page for your Vercel project.
  2. Select the Deployments tab.
  3. Click Redeploy.
  4. 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

You might also be interested in the following pages: