How it fits with Nitro UI
Nitro UI Brownfield is built on Nitro UI. This page says which part of an app belongs to which project, so you know where to look when something behaves in a way you did not expect.
Nitro UI Brownfield is an independent third-party library. It is not affiliated with, made by, sponsored by or endorsed by Margelo, the authors of Nitro UI. “Nitro UI” and “Margelo” are used only to say what this library works with.
What Nitro UI provides
Section titled “What Nitro UI provides”Nitro UI renders React components to native views: UIKit views on iOS, and native view groups, TextView and ScrollView on Android. For an app of its own, it provides:
- The components and the renderer.
nitro-ui-renderergives you components such asViewandText, andregisterAppfor an app that Nitro UI itself launches. - The command line.
nitro-ui-cliprepares, builds and runs Nitro UI apps, andcreate-nitro-uistarts a project. - The JavaScript runtime and its globals (
nitro-ui-runtime): timers,fetch,URLand console logging, among others. - Native modules through Nitro and its code generator, and the other packages around them, such as navigation and layout engines.
- The toolchain it requires: Xcode, the Android SDK and NDK, JDK, CMake and Bun. Requirements lists the versions.
What Nitro UI Brownfield adds
Section titled “What Nitro UI Brownfield adds”Nitro UI starts from React: your app is a Nitro UI app, and it owns the screen. A brownfield app is the other way round, because a native iOS or Android app already exists and owns every container. This library adds what is needed for React to live inside it.
- Native hosts. A native app places a surface in a view controller or a fragment, or in a view inside its own layout:
SurfaceViewControllerandSurfaceHostViewon iOS,SurfaceFragmentandSurfaceHostViewon Android. The native app decides when a surface opens and closes. See Surfaces in your app. - Surfaces. React components registered by name with
registerSurface. The list of surfaces and their props is the contract between the two teams. See Your first surface. - Packaging into one artifact.
nuib packageturns the React project, the engine and Nitro UI’s native code into one XCFramework for Swift Package Manager and one AAR for Maven, so the native team adds a single dependency and needs no JavaScript tooling.nuib publishversions it. See Package and publish. - A typed API per surface. The packaging step generates a Swift type and a Kotlin type for each surface, with the props as typed parameters, and
nuib checkcompares the contract with the last published one. See Check the contract. - A development loop.
nuib devopens the real native app with the React project live in it. - The patch step.
nuib patchesapplies a small set of patches to some Nitro UI packages, because Nitro UI 0.3.0 does not have everything a brownfield app needs. See Patches. - Typed calls between native and React. Coming soon. It is a separate package,
nitro-ui-brownfield-contract, and it ships after the base library. See Contracts, provide and consume.
What it does not change
Section titled “What it does not change”- The code you write. A surface is a React component built from Nitro UI’s own components. You do not learn another UI vocabulary.
- Nitro UI packages that are not patched. Only the packages named on the Patches page are modified. The others are used as they are published.
- Calls into the patched packages that existed before. Code that already calls
renderRootdirectly keeps working. The Patches page lists the changes that other code can notice. - The toolchain. The requirements are Nitro UI’s, plus the ones this library declares in its own build files.
The version rule
Section titled “The version rule”Nitro UI Brownfield supports one Nitro UI version at a time, currently 0.3.0. Pin it exactly, because the patches are made against that exact version and the patch step refuses any other. The install page shows how.