Skip to content
Tutorials Center
My learning

Topics

Lesson 6 of 39 ยท Architecture and Setup

Tauri Architecture: Core, TAO, WRY and the Webview

Understand how Tauri is built: the Rust core, the TAO windowing and WRY webview libraries, the IPC bridge, custom protocols and how one process hosts the UI.

Tauri feels like one tool, but it is a stack of cooperating pieces. Knowing the layers explains behaviors that otherwise look odd: why the frontend cannot call Rust functions directly, why assets load from a strange URL, and why some features differ per platform.

The layers

flowchart TB
  A["Your frontend (HTML, CSS, JS)"] --> B["Webview<br/>WebView2 / WKWebView / WebKitGTK"]
  B <-->|"IPC messages"| C["tauri crate (the core)<br/>commands, events, state, permissions"]
  C --> D["WRY<br/>creates and controls webviews"]
  C --> E["TAO<br/>creates windows and runs the event loop"]
  D --> F["Operating system"]
  E --> F
  C --> G["Plugins<br/>files, dialogs, shell, updater..."]

From top to bottom: your UI, the engine, the Tauri core, two low-level crates, and the operating system.

  • TAO is a cross-platform window creation and event-loop library (a fork of the Rust winit crate with additions such as menus). It makes the native window and delivers events like resize and close.
  • WRY is the cross-platform webview library. It embeds the platform's engine inside a TAO window and gives Tauri hooks for custom protocols and message passing.
  • The tauri crate is the framework you use: builder, commands, events, state management, windows, menus, tray, permissions and the plugin system. It builds on TAO and WRY.
  • Plugins are separate crates (with a matching JavaScript package) that add features such as file system access, dialogs and an updater.

You normally touch only the tauri crate and plugins. TAO and WRY are re-exported where you need them.

One process, two worlds

By default the Rust core and the webview live in the same application. On desktop the engine itself may spawn helper processes (your OS decides), but conceptually there are two worlds:

  • The Rust world has full operating-system access and your trusted code.
  • The web world is a sandboxed page. It runs untrusted-by-default JavaScript, can only use what the browser engine offers, and reaches the Rust world through IPC.

Nothing crosses by reference. Every value is copied as serialized data (JSON for commands and events; raw bytes are possible through special request types). This is why you cannot hand the frontend a Rust struct, only data that can be turned into JSON.

How IPC works

When you call invoke('greet', { name: 'Ada' }) in JavaScript, roughly this happens:

  1. The Tauri JavaScript API serializes the command name and arguments.
  2. It sends them through the webview's message channel (Tauri registers a custom protocol and a message handler with WRY, depending on platform).
  3. The core receives the request, checks the permissions for the calling window, finds your registered command and deserializes the arguments.
  4. Your Rust function runs.
  5. The core serializes the return value (or error) and answers.
  6. The JavaScript Promise resolves or rejects.

Notice step 3: every call passes through the core's check before your function runs. This single choke point is what makes the permission system possible.

Custom protocols and asset loading

In a release build your frontend files are not loaded from a web server. Tauri embeds them in the executable and serves them through a custom protocol. The page address looks like tauri://localhost on macOS and Linux, and http://tauri.localhost (or https://tauri.localhost depending on configuration) on Windows and Android. Your frontend code should not hard-code these origins; use relative paths.

Because the origin is not a normal website:

  • Cookies and localStorage belong to this local origin and live in the app's data folder.
  • Requests to the open internet follow normal browser rules, including CORS, unless you route them through Rust or a plugin.
  • Local files on disk are not readable by the page; the core must provide them. See Commands basics.

Platform differences

Windows macOS / iOS Linux
Webview WebView2 (Chromium-based) WKWebView (WebKit) WebKitGTK
Window toolkit Win32 Cocoa GTK
Custom protocol origin http(s)://tauri.localhost tauri://localhost tauri://localhost

On Android the webview is the Android System WebView.

Try it: copy semantics of IPC (stand-in)

This stand-in shows why values are copied: the "core" cannot see the frontend's object, only a JSON snapshot. It is a JavaScript model, not Tauri code.

Node.js Stand-in: IPC copies data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

The Date becomes a plain string and the original is untouched. When you design commands, send simple data: numbers, strings, booleans, arrays and plain objects.

Try it: a permission choke point (stand-in)

Here is the idea from step 3, in JavaScript: every call goes through one gate that checks what the calling window is allowed to do before running anything.

Node.js Stand-in: the IPC gate

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Even though delete_all exists, no window may call it. The real system works on the same principle with capability files; you will write them in the security chapter.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which library creates native windows and runs the event loop?

    TAO handles windows and events; WRY embeds the webview inside them.
  2. 2. Why can't the frontend receive a Rust struct directly?

    IPC copies JSON-like data between the two worlds, so only serializable values cross.
  3. 3. What serves your frontend files in a release build?

    Assets are embedded in the binary and served through a custom protocol such as tauri://localhost.
  4. 4. Where does Tauri check permissions for a command call?

    The IPC layer in the core checks the window's capabilities for every invocation.

Summary

  • Tauri stacks your frontend, the system webview, the tauri core crate, WRY and TAO.
  • The Rust world is trusted and powerful; the web world is sandboxed and reaches Rust through IPC.
  • IPC copies serialized data and every call passes through a permission check.
  • Release assets are served from a custom protocol, not a web server.
  • Webview engines and origins differ per platform.

Next: Configuration files: tauri.conf.json and Cargo.toml