Vite
Vite is a build tool that aims to provide a faster and leaner development experience for modern web projects. This guide is accurate as of Vite 8.
Checklist
Section titled “Checklist”- Use
../distasfrontendDistinsrc-tauri/tauri.conf.json. - Use
process.env.TAURI_DEV_HOSTas the development server host IP when set to run on iOS physical devices.
Example configuration
Section titled “Example configuration”-
Update Tauri configuration
Section titled “Update Tauri configuration”Assuming you have the following
devandbuildscripts in yourpackage.json:{"scripts": {"dev": "vite","build": "tsc && vite build","preview": "vite preview","tauri": "tauri"}}You can configure the Tauri CLI to use your Vite development server and dist folder along with the hooks to automatically run the Vite scripts:
tauri.conf.json {"build": {"beforeDevCommand": "npm run dev","beforeBuildCommand": "npm run build","devUrl": "http://localhost:5173","frontendDist": "../dist"}}tauri.conf.json {"build": {"beforeDevCommand": "yarn dev","beforeBuildCommand": "yarn build","devUrl": "http://localhost:5173","frontendDist": "../dist"}}tauri.conf.json {"build": {"beforeDevCommand": "pnpm dev","beforeBuildCommand": "pnpm build","devUrl": "http://localhost:5173","frontendDist": "../dist"}}tauri.conf.json {"build": {"beforeDevCommand": "deno task dev","beforeBuildCommand": "deno task build","devUrl": "http://localhost:5173","frontendDist": "../dist"}} -
Update Vite configuration:
Section titled “Update Vite configuration:”vite.config.js import { defineConfig } from 'vite';const host = process.env.TAURI_DEV_HOST;export default defineConfig({// prevent vite from obscuring rust errorsclearScreen: false,server: {// make sure this port matches the devUrl port in tauri.conf.json fileport: 5173,// Tauri expects a fixed port, fail if that port is not availablestrictPort: true,// if the host Tauri is expecting is set, use ithost: host || false,hmr: host? {protocol: 'ws',host,port: 1421,}: undefined,watch: {// tell vite to ignore watching `src-tauri`ignored: ['**/src-tauri/**'],},},// Env variables starting with the item of `envPrefix` will be exposed in tauri's source code through `import.meta.env`.envPrefix: ['VITE_', 'TAURI_ENV_*'],build: {// Tauri uses Chromium on Windows and WebKit on macOS and Linuxtarget:process.env.TAURI_ENV_PLATFORM == 'windows'? 'chrome105': 'safari13',// don't minify for debug buildsminify: !process.env.TAURI_ENV_DEBUG,// produce sourcemaps for debug buildssourcemap: !!process.env.TAURI_ENV_DEBUG,},});
Static Assets
Section titled “Static Assets”Vite only emits assets it can see at build time, such as files referenced from index.html or imported
from JavaScript, TypeScript or CSS. A path assembled at runtime (for example
img.src = './assets/photo.png') is not emitted, so it works with the dev server but is missing
from dist, and therefore from the packaged app.
How to include an asset that is only known at runtime depends on the project; Vite documents the
options in Static Asset Handling. Tauri bundles the contents of
dist as-is, so any file Vite emits or copies there is available to the app.
© 2026 Tauri Contributors. CC-BY / MIT