This guide outlines how to utilize Prisma Accelerate's connection pooling with Netlify Edge functions.
Before you begin, ensure you have the following tools installed:
-
Netlify CLI:
npm install netlify-cli -g
-
Latest version of Deno in your project
-
Set Up Environment Variables: Create an
.env
file in your project directory and define the required environment variables:DATABASE_URL="prisma://accelerate.prisma-data.net/?api_key=__API_KEY__" DIRECT_URL="postgresql://user:password@host:port/db_name?schema=public"
-
Run Migrations and Generate Prisma Client:
Execute the following commands in your terminal:
deno run -A npm:prisma migrate dev --name init
Generate your Prisma Client:
deno run -A --unstable npm:prisma generate --no-engine
-
Start Your Project:
Launch your project locally using Netlify Dev:
netlify dev
Make sure you're logged in to Netlify using the CLI:
netlify login
-
Set Environment Variables:
Update your project's environment variables on Netlify using the CLI:
netlify env:set DATABASE_URL "prisma://accelerate.prisma-data.net/?api_key=__API_KEY__"
netlify env:set DIRECT_URL "postgresql://user:password@host:port/db_name?schema=public"
-
Deploy to Netlify:
Trigger the deployment process to Netlify:
netlify deploy --prod
-
Output:
Upon successful deployment, you'll receive deployment details including logs and URLs to access your deployed application.
-
-
Test Your API:
Navigate to the
/hello
endpoint of your deployed application to verify that your API is functioning correctly.