Guide

Comparing approaches

A mobile client that wants UI it did not ship with — answers generated by a model, features from partners or other teams, screens that change without a release — has a handful of established options. They differ in what draws the UI, what the delivered code may do, and how much of the app has to change to host them. This page compares them with nsh.

#The options

What draws itWhat it can expressConfinementFit for generated UICost to the host app
Web view (H5)A browser engineAnything HTML, CSS and JS canSame-origin rules; native access through a hand-written bridgeModels write HTML well; the result looks and behaves like a web pageA browser engine per view; a bridge to maintain
Server-driven UIThe app’s own native viewsOnly the components and actions the app built in, described in JSONTotal: the schema is the limitEasy to generate, little to express: no local state or logic beyond what the schema providesA renderer for every component and its versions, in each app
Mini-program containersUsually a web engine with a proprietary layerA platform-specific framework and APIThe container’s permission modelProprietary dialect, less known to modelsA large container SDK
Over-the-air updates of a cross-platform app (React Native with a code-push service, for example)That framework’s rendererThe whole frameworkNone: updates are trusted app codeCode generated per request is not what these updates are forThe app has to be written in that framework
nshUIKit and Android viewsComponents with state, logic, animation and layout; host-registered native viewsSigned packages, a VM per view with host-set limits, capabilities granted per viewDesigned for it: one TSX module, typed API, headless checksOne view and a library in an existing native app

#How nsh differs

  • Native, not a web page. A module is made of the platform’s views, so text selection and its menu, input methods, accessibility and scrolling are the system’s own — the same reason nsh exists next to GPUI Shell.
  • More than a schema. Server-driven UI only recombines what the app already ships. An nsh module has its own state, logic, animations and layout, so a model can produce an interface the app’s developers never anticipated.
  • Confined by the host. Delivered code is untrusted. nsh checks signatures and revocations before running anything, gives each view its own VM with memory, call-time and node limits, and lets the host decide which network hosts, web pages and system settings a module may reach (Sandbox and capabilities).
  • Embedded, not adopted. The app stays native and keeps its toolchain; nsh is a view placed where a module should appear (iOS, Android).

#When another option fits better

  • The UI is a document or an existing web page: a web view shows it as it is.
  • The set of screens is fixed and small, and only content and order change: server-driven UI needs no runtime at all.
  • The whole app is written in a cross-platform framework already: its own update mechanism ships its code.

#See also