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)