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.

Features
The Replit Database tool provides the following features:- Instant setup: Add a production-ready SQL database with a single click
- Database tools: Run queries, manage database schema, and visualize data with the built-in SQL tools
- Point-in-time restore: Restore your database to a specific point in time within your specified retention period
- Usage-based billing: Pay only for the storage and data transfer you use
- Environment variables: Use environment variables in your Replit App to securely access the database
Usage
How to access the Replit Database tool
How to access the Replit Database tool
From the left Tool dock:
- Select
All tools to see a list of workspace tools.
- Select
Database.
- Select the
magnifying glass at the top to open the search tool
- Type “Replit Database” to locate the tool and select it from the results.
Add a database
Use one of the following methods to add a Replit Database integration to your Replit App:- Ask Agent to add a PostgreSQL database to your Replit App, including details on what data your Replit App should store. Agent sets up the integration, creates the database schema, and updates the app to communicate with the database.
-
From the Replit Database tool, select Create a database. When using this method, you
must create the tables and update your app to connect to the database.
Run database commands
The SQL runner is a Workspace tool that lets you run SQL commands on your database and view the results.How to access SQL runner
How to access SQL runner
From the Replit Database tool:
- Select the My Data tab
- Select
SQL runner

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 connect to your database using any PostgresSQL-compatible SQL client using the connection string
found in your environment variables.
View database connection credentials
When you add a database, the Replit Database tool automatically saves your connection credentials as environment variables in your Replit App. Your app uses the credentials to securely connect to the database and run commands.How to access your database connection credentials
How to access your database connection credentials
- Navigate to the
Replit Database tool in your workspace
- Select the
Commands tab and scroll to the Environment variables section
DATABASE_URL
: Database connection string which contains all details for a secure connectionPGHOST
: database hostnamePGUSER
: database usernamePGPASSWORD
: database password
Restore tool
The Restore tool lets you revert your database to a specific point in time. To activate this tool, you must select a retention period in the History Retention option. You can then restore from any point within that period.
- Recovering from accidental data deletion or corruption
- Reverting to a previous state for testing or debugging
- Reviewing historical data from a specific point in time
How to access the Restore tool and History Retention setting
How to access the Restore tool and History Retention setting
- Navigate to the
Replit Database tool in your workspace
- Select the
Settings tab and scroll to the Restore and History Retention sections
- Enter the target date and time in the Timestamp field
- Select Restore. Select Continue to proceed in the confirmation dialog.
Remove tool
The remove action is irreversible. Make sure to back up any important data before proceeding.
How to remove a database
How to remove a database
From the Replit Database tool:
- Select the
Settings tab
- Select Remove database and confirm by selecting Yes, Remove database
Billing and resource usage
Replit optimizes your cost savings for database usage by using Neon, a serverless database provider. Neon’s serverless capabilities include the following:- Zero infrastructure setup or maintenance
- Automatic scaling to handle your usage needs
- Compute time billing only when the database is active
To learn more about this serverless database technology, see the
Neon Compute lifecycle documentation.
How to access database usage
How to access database usage
To view your database compute time and storage usage for the current billing period, follow the steps below:From the Replit Database tool:
- Navigate to the
Replit Database tool in your workspace
- Select the
Settings tab
- Scroll to the Account resource usage section to view a usage summary
- Select View account resource limits to open the Usage page
- Scroll to Resource usage section
- Expand the PostgresSQL Storage and PostgresSQL Compute rows for details on each Replit App
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