About this project

SwiftTUI Web provides two npm packages that bring SwiftTUI apps—SwiftUI semantics drawn in terminal cells—to the browser. Author an App once and ship the same View tree, @State, and @FocusState to a web page, rendered through Canvas or DOM with a semantic accessibility tree, without rewriting or using a terminal emulator like xterm.js. A SwiftTUI app compiles to wasm32-wasi and streams a structured raster surface. The @swifttui/web package paints that surface into the page via DOM or canvas engines and mounts a real ARIA accessibility tree. The ARIA tree is a one-way semantic presentation preview: reading order, names, roles, hidden state, announcements, and runtime-origin focus are presented, but assistive-origin focus, activation, adjustment, and editing do not route back into SwiftTUI. This repository contains two of SwiftTUI's five hosts: a static WASI bundle and a localhost WebHost. The framework itself lives in SwiftTUI/swift-tui. The split keeps build-time Swift processes and filesystem work out of the browser-safe runtime, so any bundler can import the runtime. Packages: - @swifttui/web: Browser runtime—scene-manifest loading, DOM + canvas rendering, ARIA mounting, WebSocket + WASI scene bridges. - @swifttui/build: Build tooling—manifest generation, Swift WASI builds, wasm validation, and the swifttui-web CLI. Installation: Both packages publish to npm as ESM with bundled TypeScript declarations. No Bun or TypeScript toolchain needed; they contain compiled dist/ JavaScript and declarations. Install via npm or from GitHub release tarballs. Basic use: Build a SwiftTUI app to WASI with `npx swifttui-web build --package-path ./TerminalApp --app MyApp`, then mount the resulting manifest and wasm from the browser runtime using createWebHostApp and createWasmSceneRuntimeFactory. The WASI runtime requires the host page to serve Cross-Origin-Opener-Policy: same-origin and Cross-Origin-Embedder-Policy: require-corp headers for SharedArrayBuffer-backed stdin; without them the canvas stays blank. Status: beta; public API can change. A live demo runs at https://swifttui.sh/webexample. Documentation and API reference at https://swifttui.sh/docs/documentation/. Other hosts include terminal (default SwiftTUI import), native SwiftUI (swift-tui-swiftui), and Jetpack Compose (swift-tui-android). License: MIT.