N
Neon2mo ago
like-gold

Vercel Integration Preview Deployment not using Neon Branches in environment variables

When connecting the project, I set it to create neon branches for preview deployments. When creating git branches and pushing them, Vercel deploys them, but just uses the production / main neon environment variables. This is evidenced in the environment variable settings in the Vercel Dashboard as well as when doing "vercel env pull" for preview and the specific branch. When I check the Neon console, it shows the branches though.
3 Replies
correct-apricot
correct-apricot2mo ago
I don't believe you'll see the environment variable for the preview branch in the Vercel dashboard. The way it is supposed to work: 1. Developer pushes to feature branch → Vercel kicks off Preview Deployment. 2. Vercel sends a webhook to Neon → Neon creates branch preview/<git-branch>. 3. Connection string for that branch is injected into the deployment's env vars. https://neon.com/docs/guides/vercel-managed-integration#enable-automated-preview-branching-recommended The best way to validate that your preview deployment is using the branch would be to include a schema change in your feature branch (your git branch) and check if it's there. If you find that it's not working, let us know.
like-gold
like-goldOP2mo ago
So in my testing, the deployment branches are using the appropriate branches. However, when I do "vercel env pull .env.local --environment=preview --git-branch=branching-test-1" to test and iterate locally, it doesn't pull in the right URL, it just pulls in the "main" one.
correct-apricot
correct-apricot2mo ago
We're not setting the preview environment variables in Vercel so the env pull command would not pick up the branch connection string. I'll talk to the team about it. Hi, I've touched base with the development team. We currently do not support automatic branch deletion in our native vercel integration, so explicitly setting the Vercel preview env variables for each preview branch is not implemented. To do so would without automatic branch deletion would leave users to manage / delete old variable settings manually. I don't have a date for adding that functionality right now, unfortunately.

Did you find this page helpful?