running-nodejs-sidecar-in-tauri

Packages and runs Node.js applications as sidecar processes inside Tauri desktop apps.

Updated Jun 7, 2026
One-click install
npx skills add https://github.com/dt418/better-shot-x --skill running-nodejs-sidecar-in-tauri-dt418
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: running-nodejs-sidecar-in-tauri
Source: https://github.com/dt418/better-shot-x/tree/main/.agents/skills/running-nodejs-sidecar-in-tauri
Command: npx skills add https://github.com/dt418/better-shot-x --skill running-nodejs-sidecar-in-tauri-dt418

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @tauri-apps/plugin-shell, tauri-plugin-shell, @yao-pkg/pkg.

What problem does it solve? Tauri applications are built on Rust, but many useful libraries and tools only exist in the Node.js ecosystem. This Skill shows how to bundle a Node.js program as a compiled sidecar binary inside a Tauri app, so end users can run JavaScript backend logic without installing Node.js themselves. ## Core Features & Use Cases - Sidecar Packaging: Compile Node.js scripts into standalone binaries with @yao-pkg/pkg and register them via Tauri's externalBin configuration with correct Rust target triples. - Communication Patterns: Invoke the sidecar from TypeScript or Rust using the Tauri shell plugin, with support for one-shot commands, streaming stdout/stderr, and long-running HTTP servers on localhost. - Security Hardening: Configure capability permissions with argument validators, bind HTTP sidecars to 127.0.0.1, and ensure processes terminate with the app. - Use Case: You want to ship a Tauri desktop app that uses an npm-only library (e.g., a specialized parser). This Skill walks you through compiling it into a sidecar binary, wiring up permissions, and calling it from your frontend. ## Quick Start Set up a Node.js sidecar in my Tauri v2 app so I can run JavaScript logic from the frontend without requiring users to install Node.js.

Frequently Asked Questions about running-nodejs-sidecar-in-tauri

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run Node.js code inside a Tauri application?

Compile your Node.js script into a standalone binary using @yao-pkg/pkg, place it in src-tauri/binaries with the Rust target triple suffix, and register it under bundle.externalBin in tauri.conf.json. Then execute it via the Tauri shell plugin's Command.sidecar API.

How to communicate between Tauri frontend and a Node.js sidecar?

Use Command.sidecar from @tauri-apps/plugin-shell for one-shot commands returning stdout, or spawn a long-running process and stream stdout/stderr events. For persistent sidecars, run an HTTP server on 127.0.0.1 and call it with the Tauri HTTP plugin.

Does a Tauri sidecar require users to install Node.js?

No. The @yao-pkg/pkg tool bundles the Node.js runtime together with your script into a single executable binary. End users run the packaged sidecar without any Node.js installation on their machines.

Why is my Tauri sidecar binary not found at runtime?

The binary filename must end with the current Rust target triple, such as my-sidecar-x86_64-unknown-linux-gnu. Verify the name with rustc --print host-tuple and confirm the file exists in src-tauri/binaries with execute permissions on Unix.

How do I restrict sidecar command arguments in Tauri capabilities?

In capabilities/default.json, replace the permissive args: true with an explicit argument list using validators, for example a regex like \\w+ for a name parameter. This prevents arbitrary argument injection into the sidecar process.

Can a Node.js sidecar run as a long-running background server?

Yes. Spawn the sidecar with command.spawn() and have it listen on 127.0.0.1 with an HTTP server. Poll a /health endpoint to confirm startup, and kill the process when the app closes to avoid orphaned processes.