Open a Second Window in Tauri 2 | Multi-Window React + Rust Tutorial

Codegiz — Built by Claude AI · Beginner ·🌐 Frontend Engineering ·1mo ago

About this lesson

Open a second OS window from your Tauri 2 app in about fifty lines of code. The WebviewWindow API lets a React button spawn a real native window with its own URL, its own size, and its own lifecycle — no Electron, no pop-up hacks, just native windows. Source code: https://github.com/GoCelesteAI/tauri_multiwin We build MultiWin, a deliberately minimal demo: a main window with a button that opens a second window labeled "settings", and each window can close the other. The whole thing is one App.tsx and zero new Rust commands — the multi-window API is pure JavaScript. What You'll Learn: - WebviewWindow from @tauri-apps/api/webviewWindow — the JS-side API for creating windows at runtime. - Window labels — every window has a unique string label; getByLabel("settings") returns the existing one if it's already open, so you can focus instead of duplicate. - Hash-routing two views from one React app — index.html#settings lets the same bundle render either the main UI or the settings UI based on window.location.hash. - getCurrentWebviewWindow().close() — close-self pattern for the secondary window. - Capability gates — core:webview:allow-create-webview-window is the permission your capabilities/default.json needs before the API call works at runtime. - Window options that matter — width, height, title, resizable, center — set once at creation, harder to change later. Timestamps: 0:00 - Two windows. One app. Here is the build. 0:15 - Capability config — the permission gate 0:45 - App.tsx — main window and the open-settings button 2:15 - App.tsx — settings window and close-self 3:00 - Run it — click open, click close 3:45 - End screen Key Takeaways: 1. WebviewWindow is the runtime window API. import { WebviewWindow } from "@tauri-apps/api/webviewWindow"; call new WebviewWindow(label, options); the second window is born. The label is your handle for everything that follows (focus, close, listen). Pick stable label strings — "settings", "about", "preview" — and keep them in

Original Description

Open a second OS window from your Tauri 2 app in about fifty lines of code. The WebviewWindow API lets a React button spawn a real native window with its own URL, its own size, and its own lifecycle — no Electron, no pop-up hacks, just native windows. Source code: https://github.com/GoCelesteAI/tauri_multiwin We build MultiWin, a deliberately minimal demo: a main window with a button that opens a second window labeled "settings", and each window can close the other. The whole thing is one App.tsx and zero new Rust commands — the multi-window API is pure JavaScript. What You'll Learn: - WebviewWindow from @tauri-apps/api/webviewWindow — the JS-side API for creating windows at runtime. - Window labels — every window has a unique string label; getByLabel("settings") returns the existing one if it's already open, so you can focus instead of duplicate. - Hash-routing two views from one React app — index.html#settings lets the same bundle render either the main UI or the settings UI based on window.location.hash. - getCurrentWebviewWindow().close() — close-self pattern for the secondary window. - Capability gates — core:webview:allow-create-webview-window is the permission your capabilities/default.json needs before the API call works at runtime. - Window options that matter — width, height, title, resizable, center — set once at creation, harder to change later. Timestamps: 0:00 - Two windows. One app. Here is the build. 0:15 - Capability config — the permission gate 0:45 - App.tsx — main window and the open-settings button 2:15 - App.tsx — settings window and close-self 3:00 - Run it — click open, click close 3:45 - End screen Key Takeaways: 1. WebviewWindow is the runtime window API. import { WebviewWindow } from "@tauri-apps/api/webviewWindow"; call new WebviewWindow(label, options); the second window is born. The label is your handle for everything that follows (focus, close, listen). Pick stable label strings — "settings", "about", "preview" — and keep them in
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related AI Lessons

Had my Frontend Developer interview with Capgemini (Application Developer) today, and I wanted to…
Prepare for a frontend developer interview with Capgemini by reviewing JavaScript fundamentals and practicing common interview questions
Medium · JavaScript
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with 10 essential tools for modern web app development
Medium · Programming
10 Frontend Developer Tools to Boost Productivity in 2026
Boost frontend productivity with top 10 developer tools in 2026
Medium · JavaScript
The US Frontend Engineer Market in 2026: A Data-Driven Reality Check (and the Bias That Stops Us Seeing It)
US frontend engineer hiring demand peaked in 2022 and remains flat-depressed in 2026, contrary to common assumptions
Dev.to AI

Chapters (6)

Two windows. One app. Here is the build.
0:15 Capability config — the permission gate
0:45 App.tsx — main window and the open-settings button
2:15 App.tsx — settings window and close-self
3:00 Run it — click open, click close
3:45 End screen
Up next
How to Open KIT Files (CodeKit Project)
File Extension Geeks
Watch →