---
title: "Installation & Setup"
description: "Follow these steps to integrate the ORM into your Tauri project."
canonical_url: "https://docs.ctrl-neo.dev/en/tauri-sqlite-orm/installation-and-setup"
---
# Installation & Setup

Follow these steps to integrate the ORM into your Tauri project.

## 1. Install Packages

This library requires `@tauri-apps/plugin-sql`. You can install both using your preferred package manager.

<code-group>

```bash [bun]
bun add @type32/tauri-sqlite-orm @tauri-apps/plugin-sql
```

```bash [pnpm]
pnpm add @type32/tauri-sqlite-orm @tauri-apps/plugin-sql
```

```bash [npm]
npm install @type32/tauri-sqlite-orm @tauri-apps/plugin-sql
```

```bash [yarn]
yarn add @type32/tauri-sqlite-orm @tauri-apps/plugin-sql
```

</code-group>

## 2. Initialize the ORM

Create an instance of the ORM in your frontend TypeScript code. It's best practice to do this in a dedicated file and export a singleton instance.

Create a file, for example `src/lib/db/index.ts`:

```ts [src/lib/db/index.ts]
import Database from '@tauri-apps/plugin-sql'
import { TauriORM, asTauriDatabase } from '@type32/tauri-sqlite-orm'

// This is where you will define your tables and relations.
// We'll create this file in the next guide.
import * as schema from './schema'

// This will load or create a database file `main.db` in your
// app's sandboxed data directory.
const dbInstance = await Database.load('sqlite:main.db')

// Initialize the ORM with the database instance and schema.
// Passing the schema object enables automatic migrations and relation queries.
// Use asTauriDatabase() if TypeScript reports type incompatibility.
export const db = new TauriORM(asTauriDatabase(dbInstance), schema)
```

<callout color="primary" icon="i-lucide-info">

**Type compatibility:** If TypeScript reports that `Database` is not assignable to `DatabaseLike`, wrap the instance with `asTauriDatabase(dbInstance)`. This is a type assertion helper—the ORM uses `$1`, `$2`, `$3` placeholders compatible with `@tauri-apps/plugin-sql`.

</callout>

Now you're all set! The `db` object is your main entry point for all database interactions. In the next section, we'll define a schema and run our first query.


## Sitemap

See the full [sitemap](https://docs.ctrl-neo.dev/sitemap.md) for all pages.
