Overview
This post will walk you through successfully connecting Prisma to Vercel's Postgres implementation.
I work for Akkio, where I'm building out a no-code predictive AI platform. If you're looking to harness the power of AI without needing a data scientist, give us a try!
Step 1: Create a Database
First, create a PostgreSQL database through Vercel.
This will automatically add all the relevant environment variables you'll need to the Vercel project as well, which will come in handy a bit later.
Step 2: Find Your Credentials
The way I recommend doing this is as follows.
-
Install the Vercel CLI.
npm i -g vercel
should do the trick. -
Link your project.
vercel link
will walk you through the process. -
Pull your variables down.
vercel env pull
is the command you're looking for.
At this point, you'll have a .env
file locally that you can use to your exact values. The relevant variable you're looking for is POSTGRES_PRISMA_URL
.
Step 3: Plug It In!
Modify your prisma.schema
so it looks like this:
datasource db {
provider = "postgresql"
url = env("POSTGRES_PRISMA_URL")
}
This environment variable configures some stuff in the URL so that Prisma can properly connect to it. Enjoy!
Top comments (1)
If you are using vercel's postgres