First-class NativeScript 9.1 & MasonKit rendering hosts, native element vocabulary, and platform Effect Layers for Effect UI (@effect/ui).
Write one Effect UI application — with typed Schema models, pure update transitions, Query.Service data fetching, Command.Service side effects, @effect/ui-kit headless components, and shared Tailwind v4 styling — and run it across Web (BrowserHost), native iOS & Android (MasonHost), and native macOS Desktop (MacosHost) with no WebView, no Electron, no browser DOM shim, and no third-party native bridge plugins.
Effect UI is intentionally host-agnostic: its core runtime talks exclusively to a minimal public Renderer.Host<Node> interface. Until now, Effect UI shipped with two hosts — BrowserHost (web DOM) and OpenTuiHost (terminal UI) — with no native mobile or desktop UI host.
This repository brings Effect UI to native platforms through three layers in packages/effect-ui:
MasonHost(@nstudio/nativescript-effect-ui/mason) — HTML-Compatible Native Host (Strategy B) Implements@effect/ui'sRenderer.Host<Node>andHtml.Hostover@triniwiz/nativescript-masonkit(Rust/Taffy CSS Grid & Flexbox backed by real native views). UnmodifiedHtml.component(...)views and@effect/ui-kitheadless components mount directly on native UIKit and Android Views.MacosHost(@nstudio/nativescript-effect-ui/macos) — Native macOS AppKit Desktop Host Implements@effect/ui'sRenderer.Host<MacosNode>andHtml.Hostdirectly over@nativescript/macos-node-api(AppKitNSWindow,NSScrollView,NSView,NSTextField,NSPanelsheets,NSHapticFeedbackManager,NSPasteboard). Mounts the exact samePulseAppHtml.component(...)on macOS desktop with zero WebView, zero Electron, and zero Xcode build (pnpm macos).NativeVocabulary &NativeHost(@nstudio/nativescript-effect-ui/native) — Dedicated NativeScript Host (Strategy A) Modeled on@effect/ui-opentui: a strongly-typed NativeScript core vocabulary (Native.component(...)withstackLayout,gridLayout,flexboxLayout,scrollView,label,button,switch,slider,progress,textField, etc.) plusNativeCommandref commands (focus,blur,measure,animate).- Platform Effect Services (
@nstudio/nativescript-effect-ui/platform&@nstudio/nativescript-effect-ui/platform/native) Host-agnostic EffectContext.Servicedefinitions (Haptics,DeviceInfo,AppLifecycle,Clipboard) with zero platform imports in shared code, backed by:NativePlatformLayer— direct iOS (UIImpactFeedbackGenerator,UIPasteboard, etc.) & Android (VibrationEffect,ClipboardManager, etc.) SDK calls with zero native wrapper plugins.WebPlatformLayer— browser equivalents (navigator.vibrate,navigator.clipboard,matchMedia).makeTestPlatformLayer— deterministic in-memory recordings for Node Vitest suites.
- Pure-TypeScript Native Capability Subpaths (zero Swift/Kotlin/C++ bridge plugins)
@nstudio/nativescript-effect-ui/motion— UI-thread native animations via iOS CoreAnimation (UIView.animateWithDurationDelayUsingSpringWithDamping...) and AndroidViewPropertyAnimatorRenderThread springs (NativeMotion.trackMount +NativeMotion.animateToref Command) — keeps running at 60/120fps even when JS is stalled, with zero Reanimated/worklets.@nstudio/nativescript-effect-ui/sheet— Native OS bottom sheets (UISheetPresentationControllermedium/large detents, grabber, and iOS 26+ Liquid Glass passthrough on iOS; bottom-docked Material sheet on Android) via<dialog data-presentation="sheet">orNativeSheet.presentNativeSheet(...)/OpenSheetCommand.@nstudio/nativescript-effect-ui/list— Host-agnostic slot-recycledVirtualListwindowing engine (init,scrolled,measureHeight,computeWindow) rendering 1,000+ rows with a tiny constant pool of recycled native views and zero re-renders on unchanged windows.@nstudio/nativescript-effect-ui/keyboard— Direct native IMESubscription(NSNotificationCenterkeyboard frame notifications on iOS;WindowInsetsCompat.Type.ime()on Android),DismissKeyboardCommand, anddockedComposerStylehelper.@nstudio/nativescript-effect-ui/crash— Drop-inmakeHtmlCrashFallback&makeNativeCrashFallbackrecovery boundaries with EffectCauseformatting, one-tap native clipboard copy, and instant restart.@nstudio/nativescript-effect-ui/devtools—NativeDevTools.makeBridgewrapping@effect/ui'sMessageLog.makeEncodedto buffer and stream Wire frames (Hello+WireEntry) over WebSocket to@effect/ui-devtools(auto-resolving127.0.0.1on iOS Simulator and10.0.2.2on Android Emulator).
Most cross-platform architectures force a painful trade-off:
- WebView wrappers (Capacitor / Cordova / Electron): Share HTML/CSS, but carry a full browser engine, higher memory overhead, and async JSON bridges to native APIs.
- Native-only custom vocabularies (OpenTUI / React Native primitives): Share application state, but force you to rewrite views, styling, and layouts separately from the web — and write C++/Swift/Kotlin bridge modules for every native SDK.
Pairing Effect UI + NativeScript + MasonKit eliminates both trade-offs:
| Technology | Responsibility |
|---|---|
Effect UI (@effect/ui) |
Application architecture, Schema models, pure reducers, Query caching, Command/Subscription orchestration, deterministic Play testing |
| MasonKit + Rust/Taffy | Real CSS Grid, Flexbox, block/inline flow, HTML-shaped elements (div, section, button, input, dialog, p, span, …) on native views |
| NativeScript 9.1 | Direct native execution, UIKit/Android/Desktop view hosting, and unrestricted zero-bridge access to 100% of platform SDKs |
Effect Layers |
Composable, type-checked dependency injection swapping Web, Native, and deterministic Test implementations cleanly |
The result moves Effect UI beyond being merely host-agnostic to being genuinely view-portable across web and native — while still letting you drop into 100% native controls and OS APIs at any level of the tree.
flowchart TD
A["Shared Effect UI App (@ns-effect-ui/shared)<br/>Html.component + @effect/ui-kit + Tailwind v4 Tokens"] --> B["BrowserHost (Web)"]
A --> C["MasonHost (NativeScript + MasonKit)"]
B --> D["Browser DOM"]
C --> E["Rust / Taffy CSS Grid & Flexbox<br/>UIKit (iOS) · Android Views · Desktop"]
F["Effect Platform Services<br/>Haptics · DeviceInfo · AppLifecycle · Clipboard"] --> G["WebPlatformLayer"]
F --> H["NativePlatformLayer<br/>Direct OS APIs (zero plugins)"]
F --> I["TestPlatformLayer<br/>Deterministic Vitest"]
- Exact
Renderer.Host<MasonNode>contract (MasonHost.ts): ImplementscreateElement,createText,setText,setAttr,setProp,insertBefore,remove,removeChildren,parentOf,nextOf,setEvents,createContainer(forh.keepAlive),commit, andhead(updating the nativeActionBartitle reactively fromHead.title(...)). - HTML-shaped elements (
elements.ts): Maps semantic HTML tags to MasonKit views (Div,Section,P,Span,Input,TextArea,Img,Details,Summary, etc.), renders<a>as MasonKit's inline clickableA, and backs layout-bearing tags (button,li,ul,ol,label,h1–h6,dialog, tables) withCSSType(tag)subclasses of MasonKit'sDiv, so mixed flex layouts and child elements (such as@effect/ui-kit'sSwitchrendering a<span>thumb inside<button role="switch">) work while CSS tag selectors still match.<select>opens the native picker,<svg>draws with CoreAnimation shape layers (path, circle, rect, line, polyline, polygon, ellipse,gtransforms,currentColor), and<video>embeds a native player (AVPlayerViewController/VideoView). - Live native text updates:
MasonTextNodeImplexposes a prototypedatagetter/setter (nodeType: 3), which MasonKit's_installTextNodeProxyhooks automatically so Effect UI'ssetTextcalls (including asyncQuery.Serviceresolutions) update native text nodes in place without rebuilding subtrees. - Logical tree +
<dialog>top layer (dialog.ts): Maintains deterministicparentOf/nextOflinks while presenting<dialog>in a MasonKit layer stacked above the app (the browser's top layer), so dialog content keeps MasonKit hit-testing and CSS scope — with backdrop scrims, safe-area insets,.ns-dark/.ns-lighttheme inheritance, and backdrop tap / Android back-button -> Effect UIcancelevent dispatch.<dialog data-presentation="sheet">uses the native sheet. - Innermost-handler events & controlled inputs (
events.ts): Stores Effect UI event handlers as data (re-renders never detach/re-attach native listeners), delivers plain-data payloads matchingHtml.Events, collects<form>field values on<button type="submit">clicks, suppresses echo on controlledvalue/checkedwrites, and reverts rejected edits on the next microtask. - Zero-patch Tailwind v4 + MasonKit CSS pipeline (
@nstudio/nativescript-effect-ui/postcss):masonPostcssPlugins()restores what@nativescript/tailwindstrips so standard Tailwind v4 utilities (grid,grid-cols-3,flex,gap-4,md:hidden,leading-8, …) reach MasonKit's Rust/Taffy layout engine, flattens CSS nesting, and convertsoklch()/color-mix()colors — without patchingnode_modules.
// packages/shared-app/src/components/App.ts (ZERO platform imports)
export const PulseApp = Html.component({
name: 'PulseApp',
model: PulseModel,
message: PulseMessage,
queries: {
snapshot: {
query: FetchPulseSnapshot,
args: ({ model }) => ({ cycle: model.syncCycle }),
},
},
}).make({
/* init, head, update (triggering Haptics Command), view (Html + @effect/ui-kit Switch + <dialog>) */
});On Web (apps/web/src/main.ts):
const AppLayer = SharedDomainLayer.pipe(Layer.provideMerge(WebPlatformLayer));
Effect.runFork(Layer.launch(BrowserHost.mount(PulseApp, {}, document.getElementById('app')!).pipe(Layer.provide(AppLayer))));On NativeScript iOS / Android (apps/native/src/main.ts):
const AppLayer = SharedDomainLayer.pipe(Layer.provideMerge(NativePlatformLayer));
Effect.runFork(Layer.launch(MasonHost.mount(PulseApp, {}, masonRoot).pipe(Layer.provide(AppLayer))));In Node Vitest (packages/shared-app/src/components/App.test.ts):
const play = yield* Play.make(PulseApp, {});
yield* play.click(Locator.attr('id', 'filter-active'));
yield* play.click(Locator.attr('id', 'new-task-btn'));
// Asserts UI state, async Query results, AND exact Haptics Layer calls!Because both NativeScript and MasonKit target far more than iOS and Android — including macOS, Windows (WinUI / DirectWrite), Linux (GTK), and visionOS — this same architecture opens up an unusually broad surface area from one Effect UI codebase:
| Target / Capability | What NativeScript + MasonKit + Effect UI Unlocks |
|---|---|
| macOS Desktop (AppKit / Mac Catalyst) | Run the exact same MasonHost Effect UI app natively on macOS without Electron — with native menu bars, Touch ID / Keychain, multi-window (Application.openWindow in NativeScript 9.1), and tiny memory footprint. |
| Windows Desktop (WinUI 3 / NativeScript Windows) | MasonKit already ships a native Windows backend (@triniwiz/nativescript-masonkit includes index.windows.js + native Taffy layout). Same Html.component + Tailwind CSS + Effect Layers for Windows Hello, native file pickers, and system tray. |
| Linux Desktop (GTK / NativeScript Linux) | MasonKit already ships a native Linux backend (index.linux.js), enabling a single Effect UI codebase to target Web, iOS, Android, macOS, Windows, and Linux — true 6-platform native reach. |
| visionOS (Spatial Computing) | NativeScript supports visionOS runtimes with native glass materials and spatial windows alongside the same Effect state & service architecture. |
| First-Class Native Effect Service Ecosystem | Build a reusable library of typed Effect Context.Service + Layer modules powered directly by NativeScript (zero C++/Swift/Kotlin bridge boilerplate): Biometrics (Face ID / Touch ID / Android BiometricPrompt / Windows Hello), SecureStorage (Keychain / Android Keystore), Location (CoreLocation / Android Location), Camera, Bluetooth (CoreBluetooth / BLE), SQLite, Notifications, NativeWindow (iPadOS / desktop multi-window), and Widgets / iOS Live Activities. |
Native Parity for @effect/ui-kit (41 Headless Components) |
Progressively back complex @effect/ui-kit components with native platform primitives where appropriate: native bottom sheets for Drawer, native popovers for Popover/Menu/Select, native recycled collection views for VirtualList, and native accessibility/focus routing. |
| Real-Time 3D, GPU & Native Media | Mix MasonHost UI overlays directly with NativeScript SceneKit / Metal / Canvas / WebGPU views driven by Effect Subscriptions and HtmlSubscription.AnimationFrames (60/120fps CADisplayLink / Choreographer). |
| AI-Native DevTools & MCP Loop | Combine Effect UI's Schema-encoded state, explicit tagged messages, deterministic Play tests, and @effect/ui-devtools MCP server with @nativescript/vite HMR — allowing coding agents to inspect state, dispatch messages, verify Effects, and hot-reload native mobile & desktop apps in real time. |
NativeScript --compiled Horizon |
Effect UI's strict separation of Schema models, tagged messages, pure reducers, Commands, and declarative views provides clean, analyzable structure for longer-term compilation experiments targeting Swift / Kotlin. |
goetzrobin/foldkit-native (packages/effect-ui-native) is another thoughtful community exploration running Effect UI on native mobile views without React's reconciler, using @ng-native/fabric over React Native Fabric and Expo. For anyone curious how different native host architectures compare, here is a side-by-side overview of the two approaches:
| Dimension | @nstudio/nativescript-effect-ui (NativeScript + MasonKit) |
foldkit-native (@ng-native/fabric + RN Fabric / Expo) |
|---|---|---|
| Rendering Stack | NativeScript + MasonKit (Rust/Taffy) hosting UIKit, Android Views, AppKit, WinUI/WinRT, and GTK4 directly. No React, Metro, or Expo runtime. | React Native Fabric (C++ / Yoga) driven through @ng-native/fabric inside an Expo / Metro app (skips React's reconciler while reusing RN Fabric views). |
| View Model (Web and Native) | Supports both MasonHost (unmodified Html.component(...) markup and @effect/ui-kit headless components) and NativeHost (typed NativeScript widget vocabulary). |
Uses a dedicated RN-shaped vocabulary (h.view, h.text, h.pressable, h.scrollView), keeping domain logic shared while authoring native views separately. |
| Layout & Styling | Rust / Taffy supporting CSS Grid (grid-cols-*, gap-*), Flexbox, block/inline flow, standard Tailwind v4, and <dialog> mapped to native modals/sheets. |
Yoga Flexbox layout with RN style objects and @ng-native/fabric's CSS subset. |
| Native OS API Access | Direct from TypeScript via generated native .d.ts typings (UIImpactFeedbackGenerator, VibrationEffect, CoreLocation, SceneKit, WinRT, GTK4) with no bridge modules. |
Uses the Expo / React Native native module ecosystem (expo-haptics, expo-clipboard, expo-audio, or custom Swift/Kotlin Expo Modules). |
| Bundler & JS Engine | Vite (@nativescript/vite) + V8 (mobile/desktop runtimes) or Node-API (Node/Bun/Deno on desktop). |
Metro + Hermes. |
| Platform Reach | Web, iOS, Android, macOS, Windows, and Linux. | iOS and Android (React Native / Expo). |
| UI-Thread Motion | CoreAnimation (iOS) and ViewPropertyAnimator (Android) driven from TypeScript (@nstudio/nativescript-effect-ui/motion). |
Motion.animate built on react-native-worklets and react-native-reanimated. |
| Native Mobile Primitives | Pure-TypeScript subpaths for detent sheets (/sheet), recycled virtual lists (/list), IME keyboard subscriptions (/keyboard), crash recovery (/crash), and devtools Wire bridge (/devtools). |
Includes mobile-focused primitives such as VirtualList, AnchoredList for streaming chat transcripts, KeyboardBar, react-native-screens navigation/sheets, NativeCrash, and NativeDevTools. |
- Where
foldkit-native(@ng-native/fabric) is a natural fit: Apps already anchored in the Expo / React Native ecosystem that want to reuse specialized RN native views (such asreact-native-enriched-markdown,expo-audio, or@shopify/react-native-skia), or mobile-focused teams adopting itsAnchoredListstreaming-chat patterns and simulated-phone test suite. - Where
@nstudio/nativescript-effect-uiis a natural fit: Teams that want to shareHtml.component(...)views, Tailwind CSS Grid layouts, and@effect/ui-kitheadless components directly across web and native, prefer calling OS SDKs straight from TypeScript without authoring Swift/Kotlin/C++ bridge modules, or want one Effect UI host architecture extending to macOS, Windows, and Linux alongside iOS and Android.
ns-effect-ui/
├── packages/
│ ├── effect-ui/ # @nstudio/nativescript-effect-ui
│ │ └── src/
│ │ ├── mason/ # Strategy B: MasonHost, elements, styles, events, native <dialog>/sheet, services, tests
│ │ ├── desktop/ # Shared desktop HTML services, color/text helpers for macOS, Windows, and Linux
│ │ ├── macos/ # Native macOS AppKit host (MacosHost, MacosPlatformLayer, layout, monochrome styles)
│ │ ├── windows/ # Native Windows host (WindowsHost for WinUI 3 / XAML Islands / Composition, WindowsPlatformLayer)
│ │ ├── linux/ # Native Linux GTK4 host (LinuxHost, LinuxPlatformLayer)
│ │ ├── native/ # Strategy A: Native.component vocabulary, NativeHost, NativeCommand
│ │ ├── platform/ # Effect Services (Haptics, DeviceInfo, AppLifecycle, Clipboard) + Web/Native/Test Layers
│ │ ├── motion/ # UI-thread CoreAnimation (iOS) & RenderThread ViewPropertyAnimator (Android)
│ │ ├── sheet/ # Native UISheetPresentationController (iOS 26+ Liquid Glass) & Android bottom sheet
│ │ ├── list/ # 1,000+ row slot-recycled VirtualList windowing engine
│ │ ├── keyboard/ # Direct iOS NSNotificationCenter & Android WindowInsetsCompat IME Subscription
│ │ ├── crash/ # Interactive CrashReport & fallback recovery boundary for MasonHost / NativeHost
│ │ ├── devtools/ # MessageLog Wire encoding & WebSocket bridge for @effect/ui-devtools
│ │ └── testing/ # MockMasonHost for fast Node Vitest verification
│ └── shared-app/ # @ns-effect-ui/shared ("Effect Pulse", 100% shared app + CSS + Play tests)
└── apps/
├── web/ # Vite 8 + Tailwind v4 web app (BrowserHost.mount)
├── native/ # NativeScript 9.1 + @nativescript/vite + MasonKit app (iOS, Android, Windows, Linux)
├── macos/ # Native macOS AppKit desktop app (@nativescript/macos-node-api + MacosHost.run)
├── windows/ # Native Windows desktop app (@nativescript/windows / windows-napi + WindowsHost.run)
└── linux/ # Native Linux GTK4 desktop app (@nativescript/linux / linux-napi + LinuxHost.run)
pnpm install
# Type-check all 7 workspaces (strict + exactOptionalPropertyTypes)
pnpm check
# Run host unit tests + portable Effect UI Play tests in Node Vitest (18 specs)
pnpm test
# Run the Web app (BrowserHost)
pnpm dev:web
# Build the Web production bundle
pnpm build:web
# Run the NativeScript iOS / Android app (MasonHost + NativeHost)
pnpm ios
pnpm android
# Run the native desktop apps (macOS AppKit, Windows WinUI/WinRT, Linux GTK4)
pnpm macos
pnpm windows
pnpm linux- Node.js 22+ and pnpm 10+
- TypeScript with
strict: trueandexactOptionalPropertyTypes: true(required by@effect/ui) - NativeScript CLI (
npm i -g nativescript) + Xcode (for iOS/macOS) or Android SDK (for Android) to run the native app