How to change the database provider to Prisma Postgres.
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.
Start by creating a new Prisma Postgres instance via the Prisma Data Platform and get your connection string. It will look something like this:
Update your environment variables to use the new Prisma Postgres connection string:
@repo/database
Uninstall the existing dependencies…
… and install the new dependencies:
Update the database connection code to use the new Prisma Postgres adapter:
Your project is now configured to use your Prisma Postgres instance for migrations and queries.
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:
To cache a query with Prisma Client, you can add the swr
and ttl
options to any given query, for example:
Learn more in the Accelerate documentation.
To stream database change events from your database, you first need to install the Pulse extension:
Next, you need to add your Pulse API key as an environment variable:
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.
Then, update the env
package to include the new PULSE_API_KEY
environment variable:
Finally, update the database connection code to include the Pulse extension:
You can now stream any change events from your database using the following code:
Learn more in the Pulse documentation.