Agent-readable docs index: /effect-swiftui/llms.txt. Full docs in one file: /effect-swiftui/llms-full.txt. Download /effect-swiftui/docs.zip to grep all markdown files locally.

Install Effect SwiftUI and build a counter

Start with a SwiftUI app targeting macOS 14+ or iOS 17+, Xcode with Swift 5.10 or later, and Bun. To try the full counter without creating an app, run it from the source checkout.

1. Add the Swift package

In Xcode, choose File → Add Package Dependencies, enter https://github.com/tanvesh01/effect-swiftui.git, select Exact Version: 0.3.0, and add the EffectSwiftUI product to your app target.
For a SwiftPM manifest instead, add .package(url: "https://github.com/tanvesh01/effect-swiftui.git", exact: "0.3.0") to the package dependencies and .product(name: "EffectSwiftUI", package: "effect-swiftui") to your target dependencies. The Swift module is EffectSwiftUI in both cases.

2. Bundle the component

In the directory containing your app’s package.json, install the adapter and the two packages the component imports. This command targets the 0.3.0 npm release; if it isn't available in your registry yet, use the source checkout below.
bun add --exact effect-swiftui@0.3.0 effect@4.1.7 'https://pkg.pr.new/Effect-TS/ui/@effect/ui@82a1750'
@effect/ui is a commit-pinned upstream preview; a fresh install needs access to pkg.pr.new. Keep the resulting lockfile. Create src/counter.ts:
import "effect-swiftui/runtime" import * as UiSchema from "@effect/ui/UiSchema" import { component, start } from "effect-swiftui" import * as Schema from "effect/Schema" const Message = UiSchema.TaggedEnum({ Count: {} }) const Counter = component({ name: "Counter", model: Schema.Struct({ count: Schema.Number }), message: Message }).make({ init: () => ({ count: 0 }), update: { Count: ({ model }) => ({ count: model.count + 1 }) }, view: (h, model) => h.button .prop("title", `Count: ${model.count}`) .on("press", Message.Count()) }) start(Counter, {})
Import the runtime first so JavaScriptCore has text encoding support before Effect loads. Bundle the entry as a single script:
bun build src/counter.ts --target=browser --format=iife --conditions=production --minify --outfile=dist/counter.js
Add the generated file dist/counter.js to your Xcode app target’s Copy Bundle Resources. Rebuild it whenever you change the TypeScript. Bun is not required on the user's device, and the browser build target does not provide a DOM.

3. Show the counter

Replace the SwiftUI app’s entry point with the following. Load only a trusted script: the bundle runs inside your app.
import EffectSwiftUI import Foundation import SwiftUI @main struct CounterApp: App { private let script = Result { guard let url = Bundle.main.url(forResource: "counter", withExtension: "js") else { throw CocoaError(.fileNoSuchFile) } return try String(contentsOf: url, encoding: .utf8) } var body: some Scene { WindowGroup { switch script { case .success(let source): EffectSwiftUISurface(script: source) case .failure(let error): Text("Cannot load counter.js: \(error.localizedDescription)") } } } }
Run the app and press Count: 0. The SwiftUI button now reads Count: 1. Swift supplies the surface, not a second copy of the count.

Run the repository example

On a Mac, clone the SwiftUI release checkout (skip the first two commands if you already have it). The repository uses Bun 1.3.14:
git clone --branch 0.3.0 --depth 1 https://github.com/tanvesh01/effect-swiftui.git cd effect-swiftui bun install --frozen-lockfile --ignore-scripts bun run demo
The full counter adds a slider, a Count down checkbox and a ⌘I shortcut. Click the count once, drag the slider to Step: 10, check Count down, then press ⌘I: the count goes from 1 to -9.

Change the starting step

In the repository’s src/counter.ts, set step: 5 in init and run bun run demo again. The first click now takes the count from 0 to 5.
For the deprecated renderer, use the archived AppKit installation guide instead. Its host, controls and DevTools are not the SwiftUI API.