Use Neon with preview environment

Hello everyone,

I’m currently exploring the use of Neon with Preview Environments on Render.com, and I’m wondering if there are any guidelines or instructions on how to create a Neon branch when launching the Preview Environment and then automatically inject its URL into the database_url variable.

I recently came across the integration Qovery offers with Neon, as explained in this blog post: Qovery Blog - Neon Integration. This piqued my interest, and I’m curious to know if Render.com provides a similar solution.

If anyone has experience with this configuration or has any information on it, I would greatly appreciate your insights.

Thank you in advance for your assistance!

Hey Léonard,

We don’t have anything specific for Neon, our preview environments leverage our own infrastructure to create a database.

To specifically address your question, it would seem like it’s possible to achieve, although the tear down might be harder.

Preview environments can use an initialDeployhook (https://render.com/docs/preview-environments#preview-environment-initialization) when you could call the Neon API to branch your database and then use our API to add that as an environment variable to your preview service.

It would be easier to do it via their API, https://neon.tech/docs/manage/branches#branching-with-the-neon-api and https://api-docs.render.com/reference/update-env-vars-for-service then you don’t have to worry about installing their CLI - your service would have to have access to your Neon API key as well as a Render API key.

That least would get you as far as branching your DB and then connecting it to your service, we don’t have a tear down hook that would delete the branch when the PR is closed/merged though,

Hopefully that gives you some pointers,

John B
Render Support, UTC :uk:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.