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

# Quickstart

> Get started with OnDB in 5 minutes

## Step 1: Create Your App

1. Go to [app.ondb.ai](https://app.ondb.ai)
2. Create a new App to get your `appId`
3. Navigate to the "Security" tab to generate your `appKey`

## Step 2: Install the SDK

```bash TypeScript theme={null}
npm install @ondb/sdk
# or
yarn add @ondb/sdk
```

## Step 3: Initialize the Client

```typescript TypeScript theme={null}
import { createClient } from '@ondb/sdk';

const client = createClient({
  endpoint: 'https://api.ondb.io',
  appId: 'your-app-id',
  appKey: 'your-app-key'
});
```

## Step 4: Create Indexes

Creating indexes automatically creates the collections and sets up the data structure.

<Warning>
  **Indexes are Required for Production Use**

  You MUST create at least one index per collection before storing data. Without indexes:

  * Queries will be extremely slow (full collection scans)
  * The OnDB dashboard cannot display your collections
  * Your application will run in an unoptimized state
</Warning>

```typescript TypeScript theme={null}
const db = client.database('your-app-id');

// Create indexes - this also creates the collections
await db.createIndex({
  name: 'idx_users_email',
  collection: 'users',
  field_name: 'email',
  index_type: 'hash',
  unique_constraint: true,
  store_values: true
});

await db.createIndex({
  name: 'idx_users_createdAt',
  collection: 'users',
  field_name: 'createdAt',
  index_type: 'btree'
});
```

## Step 5: Store Data

```typescript TypeScript theme={null}
const result = await client.store({
  collection: 'users',
  data: [{
    email: 'alice@example.com',
    name: 'Alice',
    createdAt: new Date().toISOString()
  }]
});

console.log('Stored at block:', result.block_height);
```

## Step 6: Query Data

```typescript TypeScript theme={null}
// Using Query Builder
const activeUsers = await client.queryBuilder()
  .collection('users')
  .whereField('status').equals('active')
  .orderBy('createdAt', 'DESC')
  .limit(10)
  .execute();

console.log(`Found ${activeUsers.total} users`);
```

## That's It!

You now have a fully functional database with indexed queries, automatic payment handling, and built-in data monetization. Optional immutability is available if your use case requires on-chain verification.

## Next Steps

<CardGroup cols={2}>
  <Card title="Authentication" icon="key" href="/concepts/authentication">
    Learn about App Key and Agent Key authentication
  </Card>

  <Card title="Query Builder" icon="magnifying-glass" href="/querying/query-builder">
    Build complex queries with the fluent API
  </Card>

  <Card title="Payment Flows" icon="credit-card" href="/concepts/payment-flows">
    Understand USDC payment callbacks
  </Card>

  <Card title="CRUD Operations" icon="database" href="/crud/overview">
    Document operations
  </Card>
</CardGroup>
