Guides Claude through configuring JavaScript frontend frameworks for Tauri v2 desktop applications, including Next.js, Nuxt, Qwik, SvelteKit, and Vite with proper SSG setup, tauri.conf.json settings,...
This skill covers integrating JavaScript frontend frameworks with Tauri v2 for desktop application development.
Tauri functions as a static web host, serving HTML, CSS, JavaScript, and WASM files through a native webview. The framework is frontend-agnostic but requires specific configurations for optimal integration.
Server-side rendering (SSR) in its native form. All frameworks must be configured for static output.
{
"build": {
"beforeDevCommand": "<package-manager> dev",
"beforeBuildCommand": "<package-manager> build",
"devUrl": "http://localhost:<port>",
"frontendDist": "../<output-dir>"
}
}
Replace <package-manager> with npm run, yarn, pnpm, or deno task.
Vite is the recommended choice for SPA frameworks due to its fast development experience and simple configuration.
{
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"tauri": "tauri"
}
}
import { defineConfig } from 'vite';
export default defineConfig({
clearScreen: false,
server: {
port: 5173,
strictPort: true,
host: process.env.TAURI_DEV_HOST || 'localhost',
watch: {
ignored: ['**/src-tauri/**'],
},
},
envPrefix: ['VITE_', 'TAURI_ENV_*'],
build: {
target: process.env.TAURI_ENV_PLATFORM === 'windows' ? 'chrome105' : 'safari13',
minify: process.env.TAURI_ENV_DEBUG ? false : 'esbuild',
sourcemap: !!process.env.TAURI_ENV_DEBUG,
},
});
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devUrl": "http://localhost:5173",
"frontendDist": "../dist"
}
}
Next.js requires static export mode since Tauri cannot run Node.js servers.
output: 'export' in next.configconst isProd = process.env.NODE_ENV === 'production';
const internalHost = process.env.TAURI_DEV_HOST || 'localhost';
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'export',
images: {
unoptimized: true,
},
assetPrefix: isProd ? undefined : `http://${internalHost}:3000`,
};
export default nextConfig;
{
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"tauri": "tauri"
}
}
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devUrl": "http://localhost:3000",
"frontendDist": "../out"
}
}
out directory contains static exportsgenerateStaticParams()next/image optimization is disabled; use standard <img> or configure unoptimizedNuxt must run in SSG mode with ssr: false for Tauri compatibility.
export default defineNuxtConfig({
ssr: false,
telemetry: false,
devServer: {
host: '0.0.0.0', // Required for iOS device compatibility
},
vite: {
clearScreen: false,
envPrefix: ['VITE_', 'TAURI_'],
server: {
strictPort: true,
watch: {
ignored: ['**/src-tauri/**'],
},
},
},
});
{
"scripts": {
"dev": "nuxt dev",
"build": "nuxt build",
"generate": "nuxt generate",
"tauri": "tauri"
}
}
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run generate",
"devUrl": "http://localhost:3000",
"frontendDist": "../dist"
}
}
nuxt generate for production builds (creates static files)/server/api) are not available - use Tauri commandsSvelteKit requires the static adapter and SSR must be disabled.
npm install --save-dev @sveltejs/adapter-static
import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
fallback: 'index.html',
}),
},
};
export default config;
export const ssr = false;
export const prerender = true;
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [sveltekit()],
clearScreen: false,
server: {
port: 5173,
strictPort: true,
host: process.env.TAURI_DEV_HOST || 'localhost',
watch: {
ignored: ['**/src-tauri/**'],
},
},
envPrefix: ['VITE_', 'TAURI_ENV_*'],
});
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devUrl": "http://localhost:5173",
"frontendDist": "../build"
}
}
fallback: 'index.html' enables SPA routingbuild/ by defaultQwik requires the static adapter for Tauri compatibility.
# Create project
npm create qwik@latest
cd <project>
# Add static adapter
npm run qwik add static
# Add Tauri CLI
npm install -D @tauri-apps/cli@latest
# Initialize Tauri
npm run tauri init
{
"scripts": {
"dev": "vite",
"build": "qwik build",
"tauri": "tauri"
}
}
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devUrl": "http://localhost:5173",
"frontendDist": "../dist"
}
}
| Framework | Output Dir | Dev Port | Build Command | Key Config |
|---|---|---|---|---|
| Vite | dist |
5173 | vite build |
Standard Vite config |
| Next.js | out |
3000 | next build |
output: 'export' |
| Nuxt | dist |
3000 | nuxt generate |
ssr: false |
| SvelteKit | build |
5173 | vite build |
adapter-static |
| Qwik | dist |
5173 | qwik build |
Static adapter |
Cause: Asset prefix not configured for development server.
Solution: Configure asset prefix to point to dev server (see Next.js config example).
Cause: Code executing during SSG build time instead of runtime.
Solution:
ssr: falsewindow.__TAURI__ before API callsCause: File watcher including src-tauri directory.
Solution: Add **/src-tauri/** to watch ignore list in Vite config.
Cause: Dev server not accessible on network.
Solution: Set host to 0.0.0.0 or use TAURI_DEV_HOST environment variable.
Cause: Framework attempting server-side rendering.
Solution: Ensure SSR is disabled:
output: 'export'ssr: falseexport const ssr = false in layout| Variable | Description |
|---|---|
TAURI_DEV_HOST |
Host IP for mobile development |
TAURI_ENV_PLATFORM |
Target platform (windows, macos, linux, ios, android) |
TAURI_ENV_DEBUG |
Set during debug builds |
envPrefix: ['VITE_', 'TAURI_ENV_*']
Configure build targets based on platform webview capabilities:
build: {
target: process.env.TAURI_ENV_PLATFORM === 'windows'
? 'chrome105' // WebView2 on Windows
: 'safari13', // WebKit on macOS/Linux
}
For iOS and Android development, the dev server must be accessible on the network:
server: {
host: process.env.TAURI_DEV_HOST || '0.0.0.0',
strictPort: true,
}
Run with the appropriate mobile command:
npm run tauri ios dev
npm run tauri android dev