Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

@bitcode/tauri

Tauri 2.0 native shell for BitCode. Wraps @bitcode/components Stencil Web Components into desktop and mobile apps with offline SQLite storage, native capabilities, and offline-first sync.

What is @bitcode/tauri?

A thin Rust shell around the BitCode Stencil component library. Tauri renders the same web components that run in the browser, but adds native capabilities: local SQLite with auto-migrations, file system access, push notifications, barcode scanning, biometric auth, and encrypted storage.

The app ships as a native binary on five platforms. The bc-native.ts bridge abstracts native calls behind a clean API, with Web API fallback when running outside Tauri. The offline-store.ts intercept layer routes CRUD to local SQLite for offline models and to fetch() for online models, so existing Stencil components work without modification.

Platform support:

  • Desktop: Windows (.msi), macOS (.dmg), Linux (.deb, .AppImage)
  • Mobile: iOS (.ipa), Android (.apk, .aab)

Features

  • Five platforms from one codebase: Windows, macOS, Linux, iOS, Android
  • Offline SQLite with 6 auto-migrated tables (outbox, sync state, conflict log, number sequences, auth cache, model registry)
  • Native bridge (bc-native): 13 methods covering database, filesystem, HTTP, notifications, barcode scanning, biometric auth, device info, network status, and badge counts
  • Optional SQLite encryption via SQLCipher (feature flag: encryption)
  • Mobile plugins behind feature flag (mobile-plugins): barcode scanner, biometric authentication
  • File system access and push notifications via Tauri plugins
  • withGlobalTauri mode: Stencil components stay framework-agnostic, no npm dependency on @tauri-apps/api

Prerequisites

Quick Start

Desktop

# Install component dependencies and buildcd packages/components && npm install
# Launch desktop dev window (1280x800, resizable, centered)cd ../tauri && npm run dev:desktop

Tauri builds the Stencil components first (beforeDevCommand), then opens a native window pointing at components/www.

Mobile

cd packages/tauri
# Android (first time)
npm run build:android-init # Generate Android project
npm run dev:android # Dev mode on device/emulator# iOS (first time, macOS only)
npm run build:ios-init # Generate Xcode project
npm run dev:ios # Dev mode on simulator/device

Build Commands

ScriptCommandDescription
devcargo tauri devDesktop dev server
dev:desktopcargo tauri devDesktop dev server (alias)
dev:androidcargo tauri android devAndroid dev on device/emulator
dev:ioscargo tauri ios deviOS dev on simulator/device
buildcargo tauri buildDesktop release build
build:desktopcargo tauri buildDesktop release build (alias)
build:desktop:debugcargo tauri build --debugDesktop debug build (faster, no optimization)
build:android-initcargo tauri android initGenerate Android project (first time)
build:androidcargo tauri android buildAndroid release APK/AAB
build:android:debugcargo tauri android build --debugAndroid debug build
build:ios-initcargo tauri ios initGenerate Xcode project (first time)
build:ioscargo tauri ios buildiOS release IPA
build:ios:debugcargo tauri ios build --debugiOS debug build
iconscargo tauri icon src-tauri/icons/app-icon.png -o src-tauri/iconsGenerate all platform icons from source
checkcd src-tauri && cargo checkRust type check without full build

Release output goes to src-tauri/target/release/bundle/.

Offline Schema

Tauri creates 6 SQLite tables automatically on first launch via tauri-plugin-sql migrations. These are infrastructure tables, not user-defined models.

TablePurpose
_off_outboxPending sync operations (CREATE/UPDATE/DELETE) with idempotency keys, retry counts, envelope grouping
_off_sync_statePer-device sync state: last sync timestamp, pull version, registration info, auth cache timing
_off_conflict_logField-level conflict records with local/remote/resolved values and resolution strategy
_off_number_sequenceOffline number series generation (prefix + last sequence per table)
_off_auth_cacheCached offline credentials with expiry (72h window), user groups, device binding
_off_model_registrySchema cache: maps model names to table names and field definitions received from server

Encryption

SQLite encryption uses SQLCipher. Enable at build time:

# Install SQLCipher first# macOS: brew install sqlcipher# Ubuntu: apt install libsqlcipher-dev# Windows: vcpkg install sqlcipher
BITCODE_DB_KEY=your-secret-key cargo tauri build --features encryption

The BITCODE_DB_KEY environment variable sets the encryption key. Without it, encryption builds fall back to plain SQLite. The key is passed directly in the connection string (sqlite:bitcode.db?key=...).

Architecture

Stencil Components (@bitcode/components)
|
offline-store.ts <-- intercept layer
|
bc-native.ts bridge <-- 13 native methods
|
Tauri IPC (window.__TAURI__)
|
Rust Plugins
├── tauri-plugin-sql (SQLite + migrations)
├── tauri-plugin-fs (file system)
├── tauri-plugin-notification (push notifications)
├── tauri-plugin-barcode-scanner (mobile, optional)
└── tauri-plugin-biometric (mobile, optional)

The bc-native.ts bridge lives in the components package, not here. It checks for window.__TAURI__ (enabled by withGlobalTauri: true in tauri.conf.json) and routes native capability calls to Tauri IPC. When running in a browser without Tauri, it falls back to Web API equivalents.

The offline-store.ts intercept layer sits between Stencil components and the data-fetcher. For models marked mode: "offline", it routes CRUD to BcNative.dbSelect() / BcNative.dbExecute() (local SQLite). For online models, it passes through to normal fetch(). Existing components are unaware of which path is used.

Cargo Dependencies

CrateVersionPurpose
tauri2App framework, window management, IPC
tauri-plugin-sql2 (sqlite feature)SQLite database with migration support
tauri-plugin-fs2File system read/write
tauri-plugin-notification2Push notifications
tauri-plugin-barcode-scanner2 (optional)Barcode/QR scanning (mobile)
tauri-plugin-biometric2 (optional)Fingerprint/Face ID auth (mobile)
serde / serde_json1JSON serialization

Feature Flags

FlagWhat it enables
mobile-pluginstauri-plugin-barcode-scanner + tauri-plugin-biometric
encryptionSQLCipher connection string handling via BITCODE_DB_KEY

Neither flag is enabled by default. Desktop builds need neither. Mobile builds should enable mobile-plugins. Encryption is opt-in everywhere.

Related Repositories

RepoDescription
go-jsonJSON/JSONC programming language engine
go-json-runtimesScript runtime engines for go-json (Goja, QuickJS, Yaegi, Node.js, Python)
ui-stencil-web-components119 Stencil Web Components for enterprise UIs
ui-tauriThis repo. Tauri 2.0 native shell wrapping the component library

License

MIT

About

Tauri 2.0 native shell for BitCode. Desktop (Win/Mac/Linux) + Mobile (iOS/Android). Offline SQLite, native bridge, sync engine.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages