๐ Building a Tauri v2 + Drizzle + SQLite App โ Starter Template
A complete starter template using Tauri v2, Drizzle ORM, and SQLite โ with proxy-based queries, live previews, and working fullstack setup. No backend server needed.
โ Unlike older tutorials, this one uses Tauri v2 and solves the JSON + proxy adapter problem.
๐ฆ Whatโs Inside?
- ๐งฌ Drizzle ORM (sqlite-proxy mode)
- ๐งฑ SQLite for local database
- โก Tauri v2 for native UI
- ๐ Auto migrations on dev start
- ๐งช Working nested relations (Drizzle
with:
support)
๐งโ๐ป Getting Started
git clone https://github.com/meditto/tauri-drizzle-proxy cd tauri-drizzle-proxy pnpm install pnpm tauri dev
First time you run it, all migrations will run automatically.
๐ง If you modify your schema, run:
pnpm db:generate
๐ง How It Works
Drizzle ORM runs in sqlite-proxy
mode. All SQL is sent to the Tauri backend via a custom run_sql
command. The backend uses sqlx
to execute the query and return JSON to your UI.
This repo adds:
- โ SQL type fallback for handling subqueries + JSON columns
- โ
Custom SQLite row adapter to handle nested
.with()
queries - โ Logs & dev-friendly debug output
๐ ๏ธ Tech Stack
Layer | Tech |
---|---|
UI | React + Vite |
ORM | Drizzle ORM |
Database | SQLite |
Backend | Rust (sqlx ) |
Shell | Tauri v2 |
๐ก What Was Fixed (vs Previous Attempts)
Previous attempts to integrate Drizzle ORM with Tauri (such as tauri-drizzle-sqlite-proxy-demo) relied entirely on the tauri-plugin-sql
to run queries. This led to issues with relation loadingโespecially when returning empty records with nested relations.
This project takes a different approach:
- โ
It uses
tauri-plugin-sql
only for database creation and migrations. - โ
It implements a custom Rust SQL proxy using
sqlx
, giving full control over query execution and serialization. - โ
It includes a workaround for Drizzle ORM's limitation: when a
get
query returns an empty array, we return an empty object to avoid breaking relation parsing.
This design ensures full relation support and reliable query behavior in a Tauri + Drizzle + SQLite environment.
๐ Repo
๐ https://github.com/meditto/tauri-drizzle-proxy
Let me know if you have questions or want to contribute. Star the repo if it helped you!
Top comments (0)