new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

Tauri · all subjects

sidecar & external binaries

8 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Node.js sidecar packaging with pkg tool

Node.js applications can be packaged as self-contained binaries to be used as sidecars in Tauri applications using the pkg tool. The pkg tool compiles JavaScript or TypeScript into a binary application without requiring end-user Node.js installation. Alternative tools that compile JavaScript or TypeScript into binaries also work. Embedding the Node runtime directly into the Tauri application ships JavaScript as readable files and typically results in a larger bundle than pkg-packaged applications.

Sidecar binary naming pattern

Sidecar binaries must follow the naming pattern: `binaries/my-sidecar-<target-triple>` on Linux and macOS, and `binaries/my-sidecar-<target-triple>.exe` on Windows. The target triple can be obtained using `rustc --print host-tuple` (available in Rust 1.84.0+), or by parsing `rustc -vV` output with the pattern `/host: (\S+)/` for older versions.

Sidecar externalBin configuration

Sidecars are configured in `src-tauri/tauri.conf.json` under the `bundle.externalBin` array. The Tauri CLI automatically handles bundling of sidecar binaries when they exist in the `src-tauri/binaries/` directory with the correct naming pattern.

Shell plugin required for sidecars

To execute sidecars in a Tauri application, the shell plugin must be installed and initialized first. The plugin provides the Command API used to run sidecar binaries.

Sidecar inter-process communication methods

Sidecars can communicate with the Tauri application through multiple inter-process communication systems: command line arguments with stdout/stderr output, localhost servers, stdin/stdout pipes, or local sockets. Each method has different advantages, drawbacks, and security considerations. For short-lived processes handling single commands, command line arguments and stdout work well. For long-lived applications, alternative IPC systems should be considered.

Execute sidecar from JavaScript

Sidecars can be executed from JavaScript using the Command API from the shell plugin. Example: `const command = Command.sidecar('binaries/my-sidecar', ['hello', message]); const output = await command.execute(); console.log(output.stdout);`

Execute sidecar from Rust

Sidecars can be executed from Rust using the tauri_plugin_shell::ShellExt trait. Example: `let sidecar_command = app.shell().sidecar("my-sidecar").unwrap().arg(cmd).arg(message); let output = sidecar_command.output().await.unwrap(); String::from_utf8(output.stdout).unwrap();`

What must be validated for sidecars in Tauri 2

For sidecars in Tauri 2, the binary naming pattern must follow the convention `binaries/my-sidecar-<target-triple>` and must be placed in the `src-tauri/binaries/` directory. The sidecar must be listed in the `bundle.externalBin` configuration in `tauri.conf.json`. The shell plugin must be installed and initialized. The sidecar must have appropriate permission configuration in the capabilities file with `shell:allow-execute` identifier and `sidecar: true` flag.

Give your agent this brain