A minimal SkiaUI app that renders to a browser canvas via WebAssembly.
- Swift 6.2+
- Swift WASM SDK
Install the WASM SDK:
swift sdk install https://download.swift.org/swift-6.2.4-release/wasm-sdk/swift-6.2.4-RELEASE/swift-6.2.4-RELEASE_wasm.artifactbundle.tar.gz-
Copy this directory to start your own project:
cp -r Examples/BasicApp ~/MySkiaUIApp cd ~/MySkiaUIApp
-
Edit
Sources/App.swiftto build your UI:import SkiaUI import SkiaUIWebBridge @main struct BasicApp: SkiaUI.App { var body: some View { VStack(spacing: 16) { Text("Hello, SkiaUI!") .fontSize(28) .bold() } } static func main() { WebBridge.start(BasicApp.self) } }
-
Build and run:
./build.sh npx serve dist
-
Open
http://localhost:3000in your browser.
BasicApp/
├── Package.swift # SPM manifest with SkiaUI dependency
├── Sources/
│ └── App.swift # Entry point and UI definition
├── WebHost/
│ ├── index.html # Browser entry point (CanvasKit loader)
│ └── displayListPlayer.mjs # DisplayList binary decoder + renderer
├── build.sh # One-command WASM build script
└── README.md
swift package jscompiles Swift to WASM and generates JS glue codebuild.shcopies the WASM output + web host files intodist/index.htmlloads CanvasKit, initializes the canvas, and starts the WASM app- Swift renders UI via the SkiaUI pipeline and sends binary display list commands to
displayListPlayer.mjs - The player decodes the binary commands and draws them using CanvasKit