Co-authored by
Here’s how to switch from Neon to Prisma Postgres — a serverless database with zero cold starts and a generous free tier. You can learn more about its architecture that enables this here.
1. Create a new Prisma Postgres instance
Start by creating a new Prisma Postgres instance via the Prisma Data Platform and get your connection string. It will look something like this:2. Update your environment variables
Update your environment variables to use the new Prisma Postgres connection string:apps/database/.env
3. Swap out the required dependencies in @repo/database
Uninstall the existing dependencies…
Terminal
Terminal
4. Update the database connection code
Update the database connection code to use the new Prisma Postgres adapter:packages/database/index.ts
5. Explore caching and real-time database events
Note that thanks to the first-class integration of other Prisma products, Prisma Postgres comes with additional features out-of-the-box that you may find useful:- Prisma Accelerate: Enables connection pooling and global caching
- Prisma Pulse: Enables real-time streaming of database events
Caching
To cache a query with Prisma Client, you can add theswr
and ttl
options to any given query, for example:
page.tsx
Real-time database events
To stream database change events from your database, you first need to install the Pulse extension:Terminal
apps/database/.env
You can find your Pulse API key in your Prisma Postgres connection string, it’s the value of the
api_key
argument and starts with ey...
. Alternatively, you can find the API key in your Prisma Postgres Dashboard.env
package to include the new PULSE_API_KEY
environment variable:
packages/env/index.ts
packages/database/index.ts
page.tsx