Skip to content

Netlify DB

Netlify DB offers a production-grade serverless database instance that you or a code agent can instantly set up and deploy with a single command. Netlify DB automatically connects to your functions and environment variables, making it ideal for fast development and automated scaffolding.

This feature is in Beta.

Netlify DB is a new Postgres database integration built into the Netlify workflow, powered by Neon.

  • Build your full-stack app faster with a working serverless database instance
  • Scale when you’re ready with a full production database
  • Stay in your building flow while Netlify handles your project’s infrastructure

You have several options for starting a database instance with Netlify DB. These options are optimized for different workflows and starting points:

Add a database to your project with npx netlify db init, which ensures you have the latest Netlify CLI version and launches a database instance with the required environment variables.

Note that you will need Node.js version 20.12.2 or later to use the Netlify CLI.

  1. In your terminal, go to your project root directory and run npx netlify db init.
  1. Follow the prompts to create your database.

Note that you will want to claim your database if you want your project’s database to work beyond an initial 7-day period. Learn more about how to claim your database.

Follow these steps to set up a database for an existing project on Netlify within the Netlify UI.

  1. Go to Extensions and search for Neon database. Then, select Install.
  2. Go to your project dashboard and under Extensions in the left sidebar, select Neon.
  3. From your project’s Neon extension page, select Add database and follow any prompts to finish your setup.

Note that you will want to claim your database if you want your project’s database to work beyond an initial 7-day period. Learn more about how to claim your database.

We recommend code agents automatically add a database to a project by installing the @netlify/neon package in your project.

If you have the @netlify/neon package installed in your project, Netlify will automatically create a Neon database instance for you (if it’s not already created) whenever you build your project, such as when you run netlify dev, netlify build, or push changes locally to a Git hosting provider, which triggers a build on Netlify’s infrastructure.

Code agents can get these instructions from https://docs.netlify.com/ai-context/netlify-development.mdc. Note that you will need Node.js version 20.12.2 or later.

To set up automatic database provisioning when you build on Netlify, follow these steps:

  1. Install the npm package by running npm install @netlify/neon in your project.
  2. To create the database and required environment variables, you can do either of the following:
    • run netlify dev
    • run netlify build
    • push changes to your Git hosting provider, which will trigger a build and deployment

Note that you will want to claim your database if you want your project’s database to work beyond an initial 7-day period. Learn more about how to claim your database.

Claim your database in the Netlify UI so that you can do the following:

  • keep your database running beyond an initial 7-day period
  • unlock the full production capacity of your database and add more compute resources
  • be able to monitor your database
  • upgrade to other Neon database features

To claim your database:

  1. Go to Extensions and select Neon database.
  2. Select Connect Neon and follow the Neon account setup and authorization prompts.
  3. Returning to your project’s Neon extension page, select Claim database.

Now you should be able to fully access your Neon account.

After you’ve set up and claimed your database, you can manage it more fully in the Neon console. Check out the official Neon docs for help with this.

You can disconnect a database from your Netlify project in the Netlify UI. To fully delete a database, go to the Neon console. Learn more in the official Neon docs.

After disconnecting a database, you can connect to a different database or create a new database.

When you disconnect a database, the database is removed from your Netlify project, but the database instance remains in your Neon account. You can reconnect a disconnected database to your Netlify project at any time or delete it from your Neon account.

  1. Go to your project dashboard and under Extensions in the left sidebar, select Neon.
  2. Select Disconnect, then Confirm Disconnect and follow the prompts to disconnect your database.