Skip to main content
Replit Database uses a fully-managed SQL database that lets you add persistent data storage to your Replit App from the Workspace.
The fastest way to get started is to ask Agent to add a database to your app. Agent will set up the integration, create the database schema, and update your app to store and retrieve data.
screenshot of the database editor

Features

The Replit Database tool provides the following features:
  • Database tools: Run queries, manage database schema, and visualize data with the built-in SQL tools
  • Time travel: Restore your database to any Agent checkpoint using the rollback feature
  • Free storage: Includes 10GB of free storage for every Replit App.
  • Environment variables: Use environment variables in your Replit App to securely access the database
Prior to December 4th, 2025, the development database was hosted on Neon and has a few crucial differences. See the Legacy Neon Development Database section for more details.

Usage

You can access the Replit Database tool directly in your Replit App Workspace. The following sections guide you through setting up and managing your Database.
From the left Tool dock:
  1. Select All tools icon All tools to see a list of workspace tools.
  2. Select PostgresSQL database icon Database.
From the Search bar:
  1. Select the magnifying glass icon magnifying glass at the top to open the search tool
  2. Type “Replit Database” to locate the tool and select it from the results.

Add a database

All Replit Apps come with a database by default. You can access it by selecting the PostgresSQL database icon Database tool in your workspace. You can integrate the database with your Replit App by asking the Agent to add a PostgreSQL database to your Replit App, including details on what data your Replit App should store. The Agent will create the database schema and update your app to communicate with the database.

Restore your database to a previous state

You can revert your app and database to a previous state using the rollback feature. This feature allows you to restore your database to any checkpoint created by Agent or Assistant.
Checkpoint rollback interface showing rollback options
Make sure to select “Database” under “Additional rollback options” when restoring to the state of a checkpoint. This will restore your database to the state it was at the time of the checkpoint.

Run database commands

The SQL runner is a Workspace tool that lets you run SQL commands on your database and view the results.
From the Replit Database tool:
  1. Select the My Data tab
  2. Select SQL runner icon SQL runner
To run a query, enter the SQL statement in the text area and select the adjacent sql run icon run button as shown below:
screenshot of the SQL runner and run button

Browse and modify data visually

The Replit Database tool includes Drizzle Studio, a tool that lets you browse and modify data visually. These visual tools help you avoid syntax errors and offer the following functionality:
  • Filter and sort data to focus on specific information
  • Export data to a file for external use
  • Insert or modify row data
  • Create and manage schema, tables, views, and enums
You can access these tools in the My Data tab in the Replit Database tool. The following image shows a view from the Drizzle Studio builder interface:
image of the table structure editor
You can connect to your database using any PostgresSQL-compatible SQL client using the connection string found in your environment variables.

View connection credentials and usage

Your database connection credentials are stored as environment variables in your Replit App. These credentials are used by your app to securely connect to the database and run commands.
  1. Navigate to the PostgresSQL database icon Replit Database tool in your workspace
  2. Select either the Development or Production database
  3. Select the gear icon Settings tab (the gear icon). This tab shows the connection credentials and storage usage for your database.

Environment variables

The following environment variables are available:
  • DATABASE_URL: how to connect and authenticate to the database
  • PGHOST: database hostname
  • PGUSER: database username
  • PGPASSWORD: database password
  • PGDATABASE: database name
  • PGPORT: database port
This DATABASE_URL can only be used by your app and even if leaked, it cannot be used by anyone else to access and modify your database. To learn how to use these credentials in your code, see Connect your app to a SQL database.
Because this DATABASE_URL is scoped to your app, your development database cannot be accessed by other apps, even ones you own or external database viewers. This separation follows security best practices and prevents unauthorized access to your database.If you need multiple Replit Apps to share a single development database, see the guide on sharing a database across multiple Replit Apps.
If you are still on the legacy Neon development database, do not share your DATABASE_URL. It contains your database credentials which could be used by anyone to access and modify your database. Never paste it in public places or support tickets.

Security features

When you add a database integration using Agent, it adds an Object-Relational Mapper (ORM) that handles all database communications with built-in security. This ORM layer, combined with Agent’s security best practice implementation, protects your app from exploits through the following features:
  • Schema validation: Verifies data conforms to expected formats
  • Data sanitization: Automatically cleans up builder input to prevent SQL injection attacks

Legacy Development Database

Prior to December 4th, 2025, the development database was hosted on Neon. This database is now deprecated and all new development databases are hosted on Replit’s own database infrastructure. You can see if your development database is hosted on Neon by checking the DATABASE_URL environment variable. If it contains neon.tech/neondb, then your development database is still hosted on Neon. The following are the key differences between the legacy Neon development database and the new Replit development database:
FeatureHelium (current)Neon (legacy)
HostingHosted on Replit’s own infrastructureHosted on Neon (third-party provider)
BillingIncluded for free with every Replit AppUsage-based billing. See Publishing and Database Billing for more details.
Restore capabilityRestore your database to any checkpoint using the rollback featurePoint-in-time restore (PITR)—recover to any point within backup retention window.
Connection securityOnly accessible from within your app; never exposed publicly.Used a full connection string—if leaked, anyone could access and modify your database.
Remixing behaviorRemixing creates a new development database with copied data for isolation and security.Remixing reuses the same database for all copies, so changes in remixes could affect the original app.
Database creationAutomatically created for each Replit App.Required explicit setup.
Publishing workflowDeploying or publishing requires creating a production database for isolation between environments.Development and production shared the same database, so unintended development changes could affect production apps.