> ## Documentation Index
> Fetch the complete documentation index at: https://docs.replit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Database

> Learn how to use Replit's built-in SQL database to store and retrieve data for your app.

export const YouTubeEmbed = ({videoId, title = "YouTube video", startAt}) => {
  if (!videoId) {
    return null;
  }
  let url = "https://www.youtube.com/embed/" + videoId;
  if (startAt) {
    url = url + "?start=" + startAt;
  }
  return <Frame>
      <iframe src={url} title={title} allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowFullScreen></iframe>
    </Frame>;
};

Replit Database uses a fully-managed SQL database that lets you add persistent data storage to your Replit App from the Project Editor.

<Note>
  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.
</Note>

<Frame>
  <img src="https://mintcdn.com/replit/tlGd6oyGOaUUeRxr/images/databases/database-editor.jpg?fit=max&auto=format&n=tlGd6oyGOaUUeRxr&q=85&s=18a9293165cc5d42db6c61ea572780d1" alt="screenshot of the database editor" width="1389" height="871" data-path="images/databases/database-editor.jpg" />
</Frame>

## 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. See [Data recovery](/features/data-and-storage/data-recovery)
* **Free storage**: Includes 20GB of free storage for every Replit App.
* **Environment variables**: Use environment variables in your Replit App to securely access the database

<Info>
  Prior to December 4th, 2025, the development database was hosted on Neon and has a few crucial differences.
  See [Development and production](/features/data-and-storage/development-and-production#legacy-development-database) for more details.
</Info>

## Usage

<YouTubeEmbed videoId="zbyRuoPNIc8" title="How to use Databases on Replit" />

You can access the Replit Database tool directly in the Project Editor.
The following sections guide you through setting up and managing your Database.

<Accordion title="How to access the Database tool">
  1. Open the **Tools** pane and select **Database** under **Replit Cloud**.
  2. The landing view lists your databases. Select one, such as **Development Database**, to open it.
</Accordion>

The Database tool is organized around your list of databases. The landing view shows each database with its storage use, plus your current **Billing Period** and **Hours of Compute Used**. Opening a database gives you three tabs:

* **Overview**: The tables in your database.
* **My Data**: Browse and edit rows, or run SQL queries.
* **Settings**: The connection string, storage usage, and connection details.

### Add a database

All Replit Apps come with a database by default. You can access it by selecting the <img class="icon-svg" src="https://mintcdn.com/replit/rJldsgYVucXB_6kW/images/icons/postgres.svg?fit=max&auto=format&n=rJldsgYVucXB_6kW&q=85&s=68fc78519888560040eb7096f68e76df" alt="PostgresSQL database icon" width="24" height="24" data-path="images/icons/postgres.svg" /> **Database** tool in the Project Editor.

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.

### 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

## Next steps

* [Development and production](/features/data-and-storage/development-and-production): Your two databases, the infrastructure upgrade, and the legacy Neon comparison.
* [Work with your data](/features/data-and-storage/work-with-your-data): Browse, edit, and query your data.
* [Connection details](/features/data-and-storage/connection-details): Credentials and external tools.
* [Data recovery](/features/data-and-storage/data-recovery): Restore development or production data.
