or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

index.md
tile.json

tessl/npm-tauri-apps--cli

Command line interface for building Tauri apps with Node.js wrapper around native Rust binary

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@tauri-apps/cli@2.8.x

To install, run

npx @tessl/cli install tessl/npm-tauri-apps--cli@2.8.0

index.mddocs/

@tauri-apps/cli

@tauri-apps/cli is the command line interface for building cross-platform desktop applications with the Tauri framework. It provides a Node.js wrapper around a native Rust binary, enabling developers to scaffold, develop, build, and bundle Tauri applications through commands like tauri dev, tauri build, and tauri init.

Package Information

  • Package Name: @tauri-apps/cli
  • Package Type: npm
  • Language: TypeScript/JavaScript with native Rust binary
  • Installation: npm install -D @tauri-apps/cli

Core Imports

const { run, logError } = require("@tauri-apps/cli");

For ES modules:

import { run, logError } from "@tauri-apps/cli";

Basic Usage

Programmatic Usage

const cli = require("@tauri-apps/cli");

// Run a Tauri CLI command programmatically
try {
  await cli.run(['dev'], 'npm run tauri');
  console.log('Command completed successfully');
} catch (error) {
  cli.logError(error.message);
  process.exit(1);
}

CLI Binary Usage

The package provides a tauri binary that can be used directly:

# Initialize a new Tauri project
npx @tauri-apps/cli init

# Start development server
npx @tauri-apps/cli dev

# Build for production
npx @tauri-apps/cli build

# Or via package manager scripts
npm run tauri dev
yarn tauri build
pnpm tauri init

Architecture

The @tauri-apps/cli package consists of several key components:

  • Node.js Wrapper: High-level JavaScript API (main.js) providing Promise-based interface
  • NAPI Native Bindings: Low-level interface (index.js) connecting to native Rust binary
  • CLI Executable: Shell script (tauri.js) handling command-line invocation and argument processing
  • Native Rust Binary: Core CLI implementation providing all Tauri development commands
  • Platform Detection: Automatic detection and loading of platform-specific native binaries

Capabilities

CLI Execution

Execute Tauri CLI commands programmatically with full error handling and progress feedback.

/**
 * Execute Tauri CLI commands programmatically
 * @param args - Array of command line arguments to pass to the CLI
 * @param binName - Optional binary name for help display (defaults to detected context)
 * @returns Promise that resolves with boolean result when command completes or rejects on error
 */
function run(args: Array<string>, binName?: string | undefined | null): Promise<boolean>;

Usage Examples:

// Initialize a new Tauri project
await run(['init', '--name', 'my-app', '--template', 'vanilla']);

// Start development server with specific configuration
await run(['dev', '--config', 'tauri.dev.conf.json']);

// Build for production with debug symbols
await run(['build', '--debug']);

// Generate app icons from source image
await run(['icon', 'path/to/icon.png']);

// Show project and system information
await run(['info']);

Error Logging

Log error messages to stderr with proper formatting for CLI output.

/**
 * Log error messages to stderr
 * @param error - Error message string to log
 */
function logError(error: string): void;

Usage Examples:

try {
  await run(['build', '--invalid-flag']);
} catch (error) {
  logError(`Build failed: ${error.message}`);
  process.exit(1);
}

// Log validation errors
logError('Configuration file not found: tauri.conf.json');

CLI Commands

The following commands are available through the run() function or CLI binary:

Project Management Commands

# Initialize a new Tauri project
tauri init [options]

# Display project and system information  
tauri info

# Migrate from Tauri v1 to v2
tauri migrate

Development Commands

# Start development server with hot reload
tauri dev [options]

# Build application for production
tauri build [options]

# Bundle application for distribution
tauri bundle [options]

Mobile Development Commands

# Android development and build commands
tauri android [subcommand]

# iOS development and build commands (macOS only)
tauri ios [subcommand]

Asset and Resource Commands

# Generate application icons from source image
tauri icon [path-to-icon]

# Code signing utilities
tauri signer [subcommand]

Plugin and Dependency Commands

# Add dependencies or features to project
tauri add [dependency]

# Remove dependencies or features from project  
tauri remove [dependency]

# Plugin management commands
tauri plugin [subcommand]

Permission and Security Commands

# Permission management
tauri permission [subcommand]

# Capability management
tauri capability [subcommand]

Utility Commands

# Shell completion generation
tauri completions [shell]

# Project inspection utilities
tauri inspect [subcommand]

Platform Support

Supported Architectures

The package automatically detects and loads the appropriate native binary for:

  • Linux: x86_64-gnu, x86_64-musl, aarch64-gnu, aarch64-musl, arm-gnueabihf, arm-musleabihf, riscv64-gnu, riscv64-musl, ppc64-gnu, s390x-gnu
  • Windows: x86_64-msvc, i686-msvc, aarch64-msvc
  • macOS: x86_64, aarch64 (Apple Silicon), universal binaries
  • FreeBSD: x86_64, aarch64
  • OpenHarmony: x86_64, aarch64, arm
  • Android: arm64, arm-eabi
  • WebAssembly: WASI support for cross-platform compatibility

Runtime Requirements

  • Node.js: >= 10
  • Platform: Windows, macOS, Linux, FreeBSD, OpenHarmony, Android
  • Architecture: x64, ARM64, ARM, RISC-V, PowerPC64, s390x (platform dependent)
  • Fallback: WebAssembly (WASI) support when native binaries unavailable

Error Handling

The CLI provides structured error handling with detailed error messages:

try {
  await run(['build', '--config', 'missing-file.json']);
} catch (error) {
  // Error object contains detailed information
  console.error('Command failed:', error.message);
  
  // Log the error using the built-in logger
  logError(error.message);
  
  // Exit with error code
  process.exit(1);
}

Configuration Integration

The CLI integrates with Tauri's configuration system:

// Use custom configuration file
await run(['dev', '--config', 'tauri.dev.conf.json']);

// Pass configuration inline as JSON
await run(['build', '--config', '{"bundle":{"active":true}}']);

// Use TOML configuration
await run(['build', '--config', 'tauri.prod.conf.toml']);

Package Manager Integration

The CLI automatically detects the package manager context and adjusts help messages accordingly:

// When run via npm scripts, shows: npm run tauri
// When run via yarn, shows: yarn tauri  
// When run via pnpm, shows: pnpm tauri
// When run via bun, shows: bun tauri
// When run directly, shows: node tauri.js

Types

// Main API - Promise-based interface (main.js exports)
declare function run(
  args: Array<string>,
  binName?: string | undefined | null
): Promise<boolean>;

declare function logError(error: string): void;

// Native bindings - Callback-based interface (index.js exports)
declare function run(
  args: Array<string>,
  binName: string | undefined | null,
  callback: ((err: Error | null, arg: boolean) => any)
): void;

declare function logError(error: string): void;