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

# Kleap Database

> A built-in database and user accounts for your app

**Kleap Database** is a built-in database and authentication system for your site. When your app needs to save data or let people log in, Kleap can add a real database — a built-in database, kept private per user — without you managing any infrastructure.

<Info>
  Kleap Database is **optional and added on demand**. A simple marketing or landing site doesn't need it — it stays fast and static. You add a database only when your app needs stored data or user accounts.
</Info>

## When to Use It

Use **Kleap Database** when your app needs to:

* Save records that persist (bookings, orders, reviews, submissions you query)
* Let visitors **create accounts and log in**
* Show each user their own private data

Use **[Forms & Data](/features/forms-data)** instead when you just need to collect contact/lead/newsletter submissions — forms already save to your dashboard and send email notifications, with zero setup.

## Adding a Database

The easiest way is to ask the AI:

```
Add a booking system where visitors pick a date and time,
and store the bookings in a database
```

```
Add user accounts with email and password login,
and a dashboard where each user sees their own data
```

Kleap provisions the database for that app and wires up the code. You can also enable it from the **Database** integration in your project settings.

## User Accounts

Kleap Database includes ready-made authentication for **your site's visitors** — email and password sign-up and login, with pre-built UI components.

```
Add a login and signup page, and protect the /dashboard
page so only logged-in users can see it
```

Behind the scenes each user only sees their own data, so it stays private by default.

<Warning>
  Your site's user accounts (visitors logging into **your** app) are separate from your **Kleap account** (how you log in to build). They're two different systems.
</Warning>

## Viewing Your Data

Once a database is added, you can browse your tables and rows from the project's **Database** panel in the dashboard — no SQL required.

## Working with Data

You describe changes in plain language and Kleap handles the schema and queries:

```
Add a "status" field to bookings with values pending, confirmed, cancelled
```

```
Create a reviews table with name, rating, and comment
```

Generated pages read and write data with a simple client (each user only sees their own data):

```tsx theme={null}
// Illustrative — Kleap writes this for you
import { db } from "@/lib/kleap-db";

// Read
const { data: bookings } = await db.from("bookings").select("*");

// Write
await db.from("bookings").insert({ date, time, name });
```

## Best Practices

<AccordionGroup>
  <Accordion title="Only add a database when you need one">
    Static sites are faster and simpler. Add Kleap Database when your app genuinely needs stored data or logins.
  </Accordion>

  <Accordion title="Use Forms for simple submissions">
    Contact and lead forms are better served by built-in Forms, which notify you by email automatically.
  </Accordion>

  <Accordion title="Keep private data private">
    Each user sees only their own data by default. Keep it that way for anything private.
  </Accordion>
</AccordionGroup>

<Card title="Collect submissions with Forms" icon="table" href="/features/forms-data">
  For contact and lead forms, use built-in Forms
</Card>
