Connect a Neon Postgres Database
Connect Neon, configure a pooled Postgres connection, and test migrations on a separate database branch.
Use Neon when your Cloud Studio project needs serverless PostgreSQL and you want to test schema changes on an isolated database branch. Connecting a Neon account and connecting your app to a database are separate steps. Choose or create the database in Neon, then give the app the connection string for the branch you intend to use.
Connect Neon to your project
Connect your Neon account
Open Connectors in the BhaiCode dashboard. Select Neon, then Connect, and authorize the account that owns the database project.
Choose the database and branch
In Neon, create or open the database project and select the branch you want. A database provider entry in Studio doesn’t create a Neon database or supply its credentials. Make sure the selected branch belongs to the project you actually want to query.
Set the application connection string
Copy the connection string for that branch into the app’s server-side DATABASE_URL environment variable. Use a pooled connection for application traffic when your driver supports it; for example, an edge or serverless app can use @neondatabase/serverless.
Verify the connection
Run a read-only query from the server against a table you expect on that branch. If the app can connect but the table is missing, check the branch in Neon before changing the application code.
Test a migration off production
Create an isolated database branch for the feature you’re building. If useful, give it the same name as the code branch so reviewers can identify the pair. Matching names don’t set the connection string. Point the test environment at the Neon branch before running the migration.
Use a direct connection for schema migrations. Test the migration against representative data, then exercise the app against the changed schema before you apply the reviewed migration to production. Keep the test and production connection strings separate so a test can’t alter production data by mistake.
If you switch branches during development, update the connection string before restarting the app. Repeat your read-only check to confirm the app is using the intended schema before running another migration.
Both pooled and direct connection strings are credentials. Keep them on the server and out of source files, browser code, and logs.