リリース・改善中
Tauri ガイド · 1/6
この章は現在、英語でのみ提供しています。
This chapter walks through installing the tools Tauri needs, creating a first project and running it in development mode. It also covers editor setup and the CLI commands you will use most.
A Tauri app has two halves. The user interface is written in HTML, CSS and JavaScript and rendered by the WebView that ships with the operating system. Windowing, file access and system integration are handled by a core written in Rust. Your development machine therefore needs the Rust toolchain, the platform's WebView development libraries and, if you use a web frontend, Node.js.
Start with the system dependencies for your platform.
| Platform | What you need |
|---|---|
| Windows | Microsoft C++ Build Tools (the "Desktop development with C++" workload) and the WebView2 runtime, which is usually preinstalled on Windows 11 and current Windows 10 |
| macOS | Xcode, or just the Xcode Command Line Tools (xcode-select --install) for desktop-only work |
| Linux | WebKitGTK, build tools, OpenSSL, the app indicator library and a few others |
On Debian and Ubuntu you can install everything in one go. For other distributions, check the package names on the official prerequisites page.
sudo apt update
sudo apt install libwebkit2gtk-4.1-dev \
build-essential curl wget file \
libxdo-dev libssl-dev \
libayatana-appindicator3-dev librsvg2-devNext, install Rust with rustup, the official installer. On Windows, download and run rustup-init.exe or use winget install --id Rustlang.Rustup, and keep the MSVC toolchain as the default.
# macOS and Linux
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Verify the installation
rustc --version
cargo --versionIf you build the UI with JavaScript or TypeScript, install an LTS release of Node.js as well. Android and iOS targets additionally need Android Studio with the NDK or a full Xcode installation, but you can skip those until you move beyond the desktop.
New projects are scaffolded with create-tauri-app.
npm create tauri-app@latestThe tool asks a few questions:
com.example.myapp.You can also add Tauri to an existing web project. Install the CLI as a dev dependency and run tauri init; it creates the src-tauri folder and asks for your dev server URL, the folder with your built assets and your build commands.
npm install -D @tauri-apps/cli@latest
npx tauri initMove into the project folder, install dependencies and start the app.
cd tauri-app
npm install
npm run tauri devtauri dev first runs the beforeDevCommand from the configuration (usually the Vite dev server), then compiles the Rust core and opens the app window. The first run builds every Rust dependency and can take a few minutes; after that only changed code is recompiled. Frontend edits are hot-reloaded in place, while Rust edits trigger a rebuild and an app restart.
In development builds you can open the WebView developer tools by right-clicking and choosing Inspect, or with Ctrl+Shift+I on Windows and Linux and Cmd+Option+I on macOS.
The template frontend calls a Rust function named greet like this. Chapter 3 explains the mechanism in detail.
import { invoke } from "@tauri-apps/api/core";
const input = document.querySelector<HTMLInputElement>("#greet-input")!;
const output = document.querySelector<HTMLParagraphElement>("#greet-msg")!;
document.querySelector("#greet-form")!.addEventListener("submit", async (event) => {
event.preventDefault();
output.textContent = await invoke<string>("greet", { name: input.value });
});In VS Code, install the rust-analyzer and Tauri extensions. tauri.conf.json references a JSON schema, so configuration keys autocomplete as you type. Because the Rust code lives under src-tauri, rust-analyzer may not find it when you open the repository root; point it there in .vscode/settings.json.
{
"rust-analyzer.linkedProjects": ["src-tauri/Cargo.toml"]
}| Command | What it does |
|---|---|
npm run tauri dev | Run the app in development mode |
npm run tauri build | Build for production and create installers |
npm run tauri add fs | Add an official plugin on both the Rust and JavaScript side |
npm run tauri icon app-icon.png | Generate every icon size from one source image |
npm run tauri info | Print tool versions and diagnose the environment |
npm run tauri android init | Prepare the Android project (ios init for iOS) |
When a build fails or no window appears, run tauri info first to check for missing system dependencies.
npm create tauri-app@latest and run it with npm run tauri dev.tauri info when something looks wrong.
コメント 0件
ログイン · ログインするとコメントできます。
最初のコメントを書いてみましょう。