Examples
The repository has five example apps under apps/. Three are React projects and two are native apps that consume a packaged artifact. They are the best way to see a complete project before you write your own.
Before you run anything, install the dependencies once at the repository root.
bun install| App | Platform | What it is |
|---|---|---|
apps/playground |
iOS and Android | A plain Nitro UI app, used as a test bed for the library. |
apps/host-ios |
iOS | A React project with five surfaces, and the UIKit host that loads them from source. |
apps/host-ios-binary |
iOS | The same host, consuming the packaged XCFramework. |
apps/host-android |
Android | A React project with six surfaces, and the Android host that loads them from source. |
apps/host-android-binary |
Android | The same host, consuming the packaged AAR. |
The surfaces in the host apps
Section titled “The surfaces in the host apps”apps/host-ios and apps/host-android register their surfaces in src/surfaces.tsx with registerSurface. The iOS app has the first five below and the Android app adds KeyboardProbe. Each one stands for a case the library has to handle.
| Surface | What it shows |
|---|---|
Profile |
A full-screen surface pushed on the native navigation stack, with a userName prop. |
Counter |
An embedded block whose props the native screen changes while it is on screen. |
Wizard |
A surface with two internal steps, driven by a navigation stack inside the surface. |
Cart |
Two instances alive at once that read the same module store. |
Crasher |
A surface that throws while rendering when asked to, to show the failure path. |
KeyboardProbe |
Android only. A surface for checking keyboard behavior. |
Run the playground
Section titled “Run the playground”apps/playground is a Nitro UI app without a native host of its own. It renders a single screen and holds the harness tests of the library. Run it with the Nitro UI CLI scripts from its package.json.
cd apps/playgroundbun run ios # iOS simulatorbun run android # Android emulatorRun the iOS example
Section titled “Run the iOS example”The React project is apps/host-ios; the native app is apps/host-ios-binary.
To build the dependency the native app uses, package the React project. The first run compiles Hermes and the engine and takes several minutes.
cd apps/host-iosbun run nuib packagebun run nuib package writes a Swift package that apps/host-ios-binary links as HostUI. To work on the React code with the native app running on the booted simulator, use the development loop.
cd apps/host-iosbun run nuib dev iosThe app is named by brownfield.hosts.ios in the project’s package.json. See Run and develop for the options.
Run the Android example
Section titled “Run the Android example”The React project is apps/host-android; the native app is apps/host-android-binary. Both appear in their package.json files: the project’s brownfield key names the host app and the Maven registry directory.
cd apps/host-androidbun run nuib packagebun run nuib dev androidbun run nuib package writes the AAR to a local Maven repository that apps/host-android-binary reads. bun run nuib dev android needs a running emulator or a connected device and a debuggable build of the native app.