Getting Started
Step 0: Verify Your Setupβ
After installing the prerequisites, verify your setup by running the following commands in your terminal:
-
Deno:
deno --version
-
Rust:
rustc --version
cargo --version -
Node.js (if installed):
node --version
npm --version
Step 1: Scaffold the Projectβ
-
Open your terminal.
-
Run the following command to create a new Tauri project with Vite and TypeScript:
deno run -A npm:create-tauri-app@latest
-
Follow the prompts:
- β Project name Β· your-tauri-project
- β Identifier Β· com.your-tauri-project.app
- β Choose which language to use for your frontend Β· TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
- β Choose your package manager Β· deno
- β Choose your UI template Β· Vanilla
- β Choose your UI flavor Β· TypeScript
Step 2: Navigate to the Project Folderβ
- Move into the project folder:
cd your-tauri-project
Step 3: Install Tauri API for Denoβ
- Install the Tauri API for Deno:
deno task tauri add dialog
Step 4: Configure Viteβ
-
Open the
vite.config.ts
file in your project and ensure it looks like this:import { defineConfig } from "vite";
import deno from "vite-plugin-deno";
export default defineConfig({
plugins: [deno()],
}); -
If you donβt have
vite-plugin-deno
installed, add it:deno add vite-plugin-deno
Step 5: Set Up the Frontendβ
-
Open the
src/main.ts
file and replace its content with this basic TypeScript example:import { invoke } from "@tauri-apps/api";
// Create a button that calls a Tauri command
const app = document.querySelector<HTMLDivElement>("#app")!;
app.innerHTML = `
<h1>Hello, Tauri + Vite!</h1>
<button id="greet-btn">Say Hello</button>
<p id="message"></p>
`;
// Add event listener to the button
const greetBtn = document.querySelector<HTMLButtonElement>("#greet-btn")!;
const message = document.querySelector<HTMLParagraphElement>("#message")!;
greetBtn.addEventListener("click", async () => {
const response = await invoke("greet", { name: "Tauri User" });
message.textContent = response as string;
});
Step 6: Set Up the Tauri Backendβ
-
Open the
src-tauri/src/main.rs
file and add a simple command:#[tauri::command]
fn greet(name: &str) -> String {
format!("Hello, {}!", name)
}
fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
Step 7: Run the Development Serverβ
-
Install dependecies:
deno install
-
Start the Tauri development medium:
deno task tauri dev
This will open a desktop window with your app running.
Step 8: Build the Appβ
-
Build the production version:
deno task build
-
The installer will be located in:
- Windows:
.msi
file insrc-tauri/target/release/bundle/msi/
. - Linux:
.deb
or.AppImage
file insrc-tauri/target/release/bundle/
. - macOS:
.dmg
file insrc-tauri/target/release/bundle/dmg/
.
- Windows:
Project Structureβ
tauri-vite-app/
ββ src/ # Vite frontend (TypeScript)
β ββ main.ts # Entry point
β ββ assets/ # Static assets
ββ src-tauri/ # Tauri backend (Rust)
β ββ src/ # Rust source files
β ββ tauri.conf.json # Tauri configuration
ββ deno.json # Deno configuration
ββ vite.config.ts # Vite configuration