This sample application deploys a Next.js API route that uses Prisma ORM to Vercel Edge Functions. Support for running inside of edge functions is currently in Preview in Prisma ORM, you can learn more here.
A Vercel Postgres or Neon database (Vercel Postgres uses Neon under the hood, so you can choose either for this project).
git clone git@github.com:prisma/nextjs-edge-functions.git
cd nextjs-edge-functions
Add the connection URLs that you received after setting up the Vercel Postgres (or Neon) database to the .env
file.
POSTGRES_PRISMA_URL="your-db-connection-string-with-pgbouncer=true"
POSTGRES_URL_NON_POOLING="your-db-connection-string"
The values may look similar to this:
POSTGRES_PRISMA_URL="postgres://default:password@ep-wild-voice-61367780-pooler.us-east-1.postgres.vercel-storage.com:5432/verceldb?pgbouncer=true&connect_timeout=15"
POSTGRES_URL_NON_POOLING="postgres://default:password@ep-wild-voice-61367780.us-east-1.postgres.vercel-storage.com:5432/verceldb"
npm install
npx prisma migrate dev
npx prisma db seed
npm run dev
To deploy the app, you can use the Vercel CLI:
vercel deploy
Configure the environment variables in your Vercel project, e.g. via the dashboard UI or the vercel env
CLI command:
NEXT_PUBLIC_API_URL
: The domain of your deployed app on VercelPOSTGRES_PRISMA_URL
: The database URL that uses conneciton poolingPOSTGRES_URL_NON_POOLING
: The database URL that connects dirctly to your database
Manually re-deploy your project in Vercel to make the new environment variable configuration take effect. Select the latest deployment from the Deployment tab, click the ・・・ and then click Redeploy.