Server driven UI for SwiftUI
Server driven UI for SwiftUI means your backend describes a page as JSON and the iOS client renders native SwiftUI, not a WebView.
Read articleLong-form writing on server driven UI for SwiftUI: architecture, schema, widgets, and production notes. Documentation stays the source of truth; these articles are the why.
Server driven UI for SwiftUI means your backend describes a page as JSON and the iOS client renders native SwiftUI, not a WebView.
Read articleUIKit apps host a Flow page through FlowHostingController. The widgets are still SwiftUI. You do not rewrite the app first.
A weekend switch statement works until unknown types, nested widgets, and Swift 6. A package is FlowCore plus FlowRender plus your registry.
Flutter and React Native still ship UI as code, so layout tweaks wait on stores. SDUI ships UI as data on top of native SwiftUI.
Surface DecodeDiagnostics in debug overlays and logs. A malformed widget should be a telemetry event, not a blank screen.
WidgetView is MainActor. Swift 6 language mode is the default for Flow-UI. Register widgets that are safe to render on the main actor.
Native widgets inherit VoiceOver. The schema still has to send alt text, button traits, and type that scales.
Hex colors with dark_hex out of the box. Design tokens through ThemeProvider. Light and dark without a second payload.
PageStore can paginate and refresh. The backend still describes the widgets. The host supplies the next cursor through PageLoader.
Cache the page document in your PageLoader. The framework does not ship a cache. Stale-while-revalidate is a host policy.
Flow-UI does not fetch. Your PageLoader does. URLSession, GraphQL, a fixture file: all valid as long as they return a page document.
An api action round-trips to your backend. The response can mutate the page: replace a widget, patch a section, toast.
`open_bottom_sheet` carries a sheet envelope: detents, header, sections, footer. The client presents native SwiftUI, not a web modal.
Flow-UI does not ship a router. A deeplink action is data. Your app’s handler decides NavigationStack, tabs, or an external URL.
Taps carry declarative actions: toast, sheet, api, deeplink, dismiss, refresh. The dispatcher chains host handlers.
SwiftUI diffs identity. SDUI widgets need stable ids across refresh so steppers and expansion state do not reset.
Old binaries will see new type strings. Version the contract additively. Unknown widgets must fallback. Optional: host sends a capability header.
Unknown widget types and malformed payloads are dropped with a key path. The rest of the page still renders.
Last registration wins. Override a starter widget by registering the same type string with your view. No fork of the package.
Nesting is a widget that holds more widgets. Accordion is the starter example: decode children through the same registry.
Starter widgets are examples you can override: title block, image text card, banner, tag rail, stepper, accordion, separator, button row.
The registry is the only AnyView erasure point. WidgetView stays generic. WidgetContext is how a widget talks to state and actions.
Teach Flow-UI a new widget in three steps from your app: model the payload, write the SwiftUI view, register it.
A closed Codable enum of widgets cannot learn a type the binary does not name. An open registry can, and unknown types degrade instead of failing the page.
A SwiftUI component registry maps a backend type string to a payload model and a view. One register call. No framework enum of widgets.
Padding, margin, corners, gradients, and width come from the widget layout object and apply in one fixed modifier order.
Atoms are the reusable JSON shapes behind widgets: TextData, ColorData, ImageData, FontData. Dark variants live on the color atom.
A SwiftUI JSON schema for SDUI is the envelope plus widget layout and atoms. It is a contract, not a visual builder file.
The Flow-UI JSON envelope is a page with optional header and footer, sections, and widgets. One document describes the whole native screen.
PageStore owns the decoded page. WidgetStateStore owns per-widget state. SwiftUI Observation is how the view tree stays in sync.
Dynamic SwiftUI screens are pages the backend composes. The client does not hardcode the widget list; it renders whatever the envelope contains.
Flow-UI renders JSON as SwiftUI on iOS 17 using Observation and PageStore. Paste a payload in the playground to see the same pipeline.
JSON becomes SwiftUI when the registry maps a type string to a WidgetView and the renderer emits that view for each widget in the page.
An SDUI page is sections of widgets. That envelope is the whole contract. Screens and cards are not types in Flow-UI.
The rendering engine walks sections, resolves each widget type in the registry, and lays out native SwiftUI. Unknown types drop out.
A server driven UI architecture on iOS is decode, registry, contain failures, render widgets, dispatch actions. Flow-UI names those types.
A JSON page that picks among widgets already in the binary is data. Downloaded executable code is not. Keep the payload declarative.
Feature flags toggle code you already shipped. Remote config swaps copy and numbers. SDUI rearranges native widgets from JSON. They stack; they are not the same.
Skip SDUI for maps, heavy gestures, latency-critical canvases, and apps that change UI once a quarter. Use it for feeds, merchandising, onboarding, and experiments.
Native SDUI means the widget is a real SwiftUI view: scrolling, gestures, and accessibility come from the platform, not from HTML.
Implement SDUI on iOS by decoding a page envelope, registering widgets, containing unknown types, and dispatching actions as data.
Build server driven UI in SwiftUI with four pieces: a JSON envelope, a widget registry, a renderer, and host networking. Worked path using Flow-UI.
SDUI renders native SwiftUI from JSON. A WebView renders HTML in a browser process. Teams pick SDUI when the page should feel like the rest of the app.
API driven UI and remote UI are names for the same idea as server driven UI: the API returns page structure, the iOS app paints SwiftUI.
Backend driven UI, server driven UI, BDU, and SDUI are the same split: the server describes the page, the client renders native views.
SDUI for Swift is a JSON envelope, an open widget registry, and a renderer. Not a new language, not a downloaded script.
SDUI on iOS is native SwiftUI rendered from a JSON page. A WebView is a different product with different scrolling, gestures, and accessibility.