# Database

Source: https://layerwise.app/docs/deploy/database

Every project ships with a built-in production database — no third-party service to set up.

Every project includes its own database. It is provisioned automatically, bound to your app, and deployed with each release, so there is no separate database service to sign up for, configure, or connect.

## How it works [#how-it-works]

- Each project gets one dedicated **SQLite database** (Cloudflare D1) exposed to your app as the `DB` binding.
- Locally, the app runs against a local SQLite file so you can build and test offline.
- On [publish](./publish), the production database is created on first release and your schema migrations are applied automatically.

Because it is standard SQLite, the generated app talks to it through an ORM and ordinary SQL — nothing Layerwise-specific to learn.

## View and edit your data [#view-and-edit-your-data]

Open **Database** from the project sidebar to browse and edit your data directly, no SQL required.

- Switch between **Local** and **Online** at the top of the page to work with your local development data or your live production data. Online becomes available once you have [published](./publish) the project.
- The left panel lists your tables with a search box. Single-click a table to preview it, double-click to keep it open in a pinned tab.
- Click a column header to **sort**, and page through large tables at the bottom.
- **Add a row** with Insert, **edit a value** by double-clicking a cell, and **delete rows** by selecting them and choosing Delete. True/false and date/time columns show the right control — a dropdown, a date & time picker — so you never enter raw `0`/`1` or timestamps.
- **Export** the current table to CSV or JSON from the menu; the file is saved and revealed in your file browser.

Local and Online are independent databases — your local file is for building and testing, and production is created on first publish. Edits made to **Online** change your live production data immediately.

![Database browser with environment tabs, table list, Insert, and Export controls marked; records are blurred](/docs/screenshots/database.webp)

_(1) Choose Local or Online, (2) select a table, then use (3) Insert or (4) Export. Record contents are blurred._

## Restore the online database [#restore-the-online-database]

To undo changes to live data, choose **Online**, open the menu next to the **Database** title, and choose **Restore**. Pick a time in the last 30 days, or any time since the database was created if it's newer, then type the project name to confirm.

- Rows and table structure go back to that time.
- Sign-ups and sign-ins after that time are lost.

If a later publish changed the tables, the live app may break until you publish again. To undo the restore, choose **Undo** in the message that confirms it. Viewers can't restore a database.

## Storage limits [#storage-limits]

Database storage is billed per GB-month from your team's credits. Each project gets one database, and your plan sets how many databases you can have and how large each one can grow:

| Plan       | Databases | Storage per database |
| ---------- | --------- | -------------------- |
| Free       | 1         | 100 MB               |
| Pro        | 10        | 10 GB                |
| Business   | 100       | 10 GB                |
| Enterprise | Unlimited | 10 GB                |

10 GB is Cloudflare's limit for a single database, so it's the same on every paid plan and can't be raised. Changing plans takes effect immediately: upgrading from Free raises the limit right away, and downgrading to Free applies the 100 MB limit at once.

## Monitor usage [#monitor-usage]

Open the menu next to the **Database** title and choose **Usage** to see how much of the limit the selected database uses and how much remains. The **Publish** menu in the preview header also shows the online database's size and limit, with a color indicator as it fills up. Both show the latest measurement each time you open the menu.

## When a database fills up [#when-a-database-fills-up]

As a database approaches its limit, Layerwise notifies everyone who has worked on the project — by email and in the app — at 50%, 75%, 85%, 95%, and 100% of the limit.

At **100%**, the published app becomes read-only. Pages keep loading, but the app can't save changes, so the database stops growing. To make it writable again:

- **Free up space** in the database, for example by deleting rows from the **Online** view of the Database page. Layerwise checks database size every hour, so the app can save changes again within an hour, or
- On Free, **upgrade your plan** for a 10 GB limit. The app recovers right away.

## Related [#related]

- [Publish a project](./publish)
- [Release history](./release-history)
- [Storage](./storage)
