<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Med Djelaili</title>
    <description>The latest articles on DEV Community by Med Djelaili (@meddjelaili).</description>
    <link>https://dev.to/meddjelaili</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F115229%2Ff9894562-9088-4f84-b161-4fcc25d1bde9.jpeg</url>
      <title>DEV Community: Med Djelaili</title>
      <link>https://dev.to/meddjelaili</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/meddjelaili"/>
    <language>en</language>
    <item>
      <title>🚀 Building a Tauri v2 + Drizzle + SQLite App — Starter Template</title>
      <dc:creator>Med Djelaili</dc:creator>
      <pubDate>Sat, 21 Jun 2025 18:37:00 +0000</pubDate>
      <link>https://dev.to/meddjelaili/building-a-tauri-v2-drizzle-sqlite-app-starter-template-15bm</link>
      <guid>https://dev.to/meddjelaili/building-a-tauri-v2-drizzle-sqlite-app-starter-template-15bm</guid>
      <description>&lt;h1&gt;
  
  
  🚀 Building a Tauri v2 + Drizzle + SQLite App — Starter Template
&lt;/h1&gt;

&lt;p&gt;A complete starter template using &lt;strong&gt;Tauri v2&lt;/strong&gt;, &lt;strong&gt;Drizzle ORM&lt;/strong&gt;, and &lt;strong&gt;SQLite&lt;/strong&gt; — with proxy-based queries, live previews, and working fullstack setup. No backend server needed.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;✅ Unlike older tutorials, this one uses &lt;strong&gt;Tauri v2&lt;/strong&gt; and solves the JSON + proxy adapter problem.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  📦 What’s Inside?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🧬 &lt;strong&gt;Drizzle ORM (sqlite-proxy mode)&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🧱 &lt;strong&gt;SQLite&lt;/strong&gt; for local database&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Tauri v2&lt;/strong&gt; for native UI&lt;/li&gt;
&lt;li&gt;🔁 &lt;strong&gt;Auto migrations&lt;/strong&gt; on dev start&lt;/li&gt;
&lt;li&gt;🧪 Working nested relations (Drizzle &lt;code&gt;with:&lt;/code&gt; support)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧑‍💻 Getting Started
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/meditto/tauri-drizzle-proxy
&lt;span class="nb"&gt;cd &lt;/span&gt;tauri-drizzle-proxy
pnpm &lt;span class="nb"&gt;install
&lt;/span&gt;pnpm tauri dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First time you run it, all &lt;strong&gt;migrations will run automatically&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🧠 If you modify your schema, run:&lt;/p&gt;


&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm db:generate
&lt;/code&gt;&lt;/pre&gt;

&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  🧠 How It Works
&lt;/h2&gt;

&lt;p&gt;Drizzle ORM runs in &lt;code&gt;sqlite-proxy&lt;/code&gt; mode. All SQL is sent to the Tauri backend via a custom &lt;code&gt;run_sql&lt;/code&gt; command. The backend uses &lt;code&gt;sqlx&lt;/code&gt; to execute the query and return JSON to your UI.&lt;/p&gt;

&lt;p&gt;This repo adds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ SQL type fallback for handling subqueries + JSON columns&lt;/li&gt;
&lt;li&gt;✅ Custom SQLite row adapter to handle nested &lt;code&gt;.with()&lt;/code&gt; queries&lt;/li&gt;
&lt;li&gt;✅ Logs &amp;amp; dev-friendly debug output&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🛠️ Tech Stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Tech&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;UI&lt;/td&gt;
&lt;td&gt;React + Vite&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ORM&lt;/td&gt;
&lt;td&gt;Drizzle ORM&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;SQLite&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Backend&lt;/td&gt;
&lt;td&gt;Rust (&lt;code&gt;sqlx&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shell&lt;/td&gt;
&lt;td&gt;Tauri v2&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  💡 What Was Fixed (vs Previous Attempts)
&lt;/h3&gt;

&lt;p&gt;Previous attempts to integrate Drizzle ORM with Tauri (such as &lt;a href="https://github.com/tdwesten/tauri-drizzle-sqlite-proxy-demo" rel="noopener noreferrer"&gt;tauri-drizzle-sqlite-proxy-demo&lt;/a&gt;) relied entirely on the &lt;code&gt;tauri-plugin-sql&lt;/code&gt; to run queries. This led to issues with relation loading—especially when returning empty records with nested relations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This project takes a different approach&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ It &lt;strong&gt;uses &lt;code&gt;tauri-plugin-sql&lt;/code&gt; only for database creation and migrations&lt;/strong&gt;.
&lt;/li&gt;
&lt;li&gt;✅ It &lt;strong&gt;implements a custom Rust SQL proxy&lt;/strong&gt; using &lt;code&gt;sqlx&lt;/code&gt;, giving full control over query execution and serialization.
&lt;/li&gt;
&lt;li&gt;✅ It includes a &lt;strong&gt;workaround for Drizzle ORM's limitation&lt;/strong&gt;: when a &lt;code&gt;get&lt;/code&gt; query returns an empty array, we return an empty object to avoid breaking relation parsing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This design ensures full relation support and reliable query behavior in a Tauri + Drizzle + SQLite environment.&lt;/p&gt;




&lt;h2&gt;
  
  
  📚 Repo
&lt;/h2&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/meditto/tauri-drizzle-proxy" rel="noopener noreferrer"&gt;https://github.com/meditto/tauri-drizzle-proxy&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Let me know if you have questions or want to contribute. Star the repo if it helped you!&lt;/p&gt;

</description>
      <category>tauri</category>
      <category>drizzle</category>
      <category>sqlite</category>
    </item>
  </channel>
</rss>
