DEV Community

Mohamed Djelaili
Mohamed Djelaili

Posted on

πŸš€ Building a Tauri v2 + Drizzle + SQLite App β€” Starter Template

πŸš€ 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
Enter fullscreen mode Exit fullscreen mode

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)