# Contributing ## How it fits together Nitro Core handles calls between JavaScript and native code. React renders native UIKit and Android views, Hermes runs the JavaScript, and Rolldown bundles it. Layout comes from a provider chosen at build time: Lynx Starlight by default, or Yoga ([selecting a provider](packages/nitro-ui-layout/README.md)). ## Setup You need Bun, CMake, Ninja and Clang, plus Xcode 27 for iOS. ```sh git submodule update --init --recursive bun install ``` Install prepares native sources from the pinned `nitro-core` npm package and builds the matching Hermes compilers and shared layout bindings. After that you can open the example app in Xcode. `packages/nitro-core/native` links to the installed dependency and is ignored by Git. The local `Package.swift` supplies this host's build settings. `workspaces.catalog` in the root `package.json` pins `nitro-core` and `nitrogen`. Keep both on the same exact upstream release. After an upgrade, run `bun install` and `bun run specs`. Run `bun run typecheck` from the root to check the packages, example app, starter template, tests, and repository scripts. For type checking alone, `bun install --frozen-lockfile --ignore-scripts` installs the dependencies without building native code. ## Android example Open `apps/example/android` in Android Studio, or: ```sh cd 'apps/example/android' ./gradlew :app:assembleDebug ``` This needs JDK 17, SDK 36, NDK 29.0.14206865, CMake 3.22.1, Ninja, Python 3 and Bun. Release builds link the React framework into the runtime and compile app code to Hermes bytecode. Host and lifecycle details are in [the runtime README](packages/nitro-ui-runtime/README.md). ## Docs site The [guides](docs/content/docs) are MDX. To preview them: ```sh cd docs bun install bun run dev ``` The release converts the guides to Markdown for the `nitro-ui-cli` package with `scripts/docsMarkdown.ts`. It fails on MDX syntax or `meta.json` entries it does not handle, so update it when adding new syntax. Run `bun run typecheck` in `docs/` to generate route types and check the site. ## Apps and the CLI The starter imports components and `registerApp` from `nitro-ui-renderer`, and generates `ios/` and `android/` projects that the app owns from then on. `nitro-ui-cli` turns installed packages and local `Modules/` into source links and build metadata under `.nitro/`. Apps upgrade with `bun add nitro-ui-cli@latest nitro-ui-renderer@latest` ([CLI guide](packages/nitro-ui-cli/README.md)). Release builds compile React and the renderer to native code with Static Hermes. App components load from Hermes bytecode. ## Sharing files between CI jobs When a change needs Android functional tests, the example app workflow uploads the debug APK and its metadata as a GitHub Actions artifact for one day. The ADC job downloads it by ID, so retrying the tests uses the APK from the successful build. Fork pull requests and Dependabot runs skip ADC because it requires the `ADC_API_KEY` secret. ## Contributing performance coverage When adding a runtime feature or changing one that lacks performance coverage, include a Release Harness scenario in the PR. Exercise the same public operation with a fixed amount of work on both revisions. For a new API with no comparable operation on the base revision, calibrate the workload with two builds of the introducing revision to establish a baseline for future PRs. A change made to improve performance always needs a scenario that measures the improved operation, on each platform it affects. The scenario shows the gain on the PR and catches a later regression. Put it in the same PR. If the PR is already open without one, add it there or open a stacked PR on top with it. For an iOS-only change, add the workload to the [iOS Release Harness](scripts/performance/ios/README.md#release-harness-renderer-smoke). A scenario prepares the app state, returns a `run()` function for the measured operation, and checks the native outcome in `verify()`. Keep setup, assertions and cleanup outside the measurement. The mount benchmark commits a fresh tree and checks the text of every native label. The update benchmark prepares its tree before measurement, updates existing rows and verifies that the same native views received the final properties. The image benchmark mounts photos from a native tap, ends each round with the frame that draws them and checks every displayed bitmap. For interactions that span presented frames, record frame counts and jank for that interaction. [Renderer examples](scripts/performance/scenarios/render.tsx) ยท [Android benchmark guide](scripts/performance/README.md) Register the scenario with the suite and keep its measured window identical for baseline and candidate. If the new metric should inform merge decisions, declare it in the report's primary comparison family before inspecting results. Use an A/A comparison to estimate noise and a known extra workload to check sensitivity. Run `python3 scripts/performance/scenarios/report.py --markdown ` on the completed measurements. The default study collects 64 pairs on a single device. The primary intervals share a 5% error budget. The practical regression margins are a 5% increase in elapsed time or CPU work and a 5-percentage-point increase in scroll jank. The scroll rate is 100 times the number of reported scroll frames that exceeded their Android frame deadline divided by the total number of reported frames in the same scroll interaction. For example, an increase from 8% janky frames to 14% is six percentage points. The effect must clear the margin across the whole interval. Device scheduling and the changes between the two checkouts affect precision. Results can remain inconclusive at the selected endpoint. The report is advisory locally. PR checks use `--require-non-regression`. A confirmed regression exits 2 and incomplete primary coverage exits 3. For the renderer and workload metrics, an interval that still permits a meaningful regression exits 4 for review. The report shows inconclusive startup and theme timings alongside the pass/fail decision. Keep the raw SDK window and frame counts with the report so reviewers can inspect the measurements. [Feature-suite report](scripts/performance/scenarios/report.py) ## Releases The SDK packages have unscoped names and share one version, `X.Y.Z` or `X.Y.Z-alpha.N`. The upstream Nitro dependency keeps its own pinned version. If an SDK change means existing apps have to edit their native projects, bump that platform's version in `packages/nitro-ui-cli/native-project.json`, add a versioned guide under `packages/nitro-ui-cli/upgrades/`, and update the starter's native template in the same change. Package-only changes leave the native revision alone, so app upgrades don't ask for native edits they don't need. ### Hermes compilers The host compilers ship as `nitro-hermes-linux-x64`, `nitro-hermes-windows64` and `nitro-hermes-darwin-arm64`. Their versions come from the Hermes submodule commit and the compiler build recipe. The SDK lists all three as optional dependencies, so the package manager installs the one for the build machine. When a Hermes update lands on `main`, the Linux and Windows Hermes compilers workflows build their packages on GitHub-hosted runners and submit them with `npm stage publish`. They authenticate with npm trusted publishing (OIDC), so there is no npm token in the repository. Each package's settings on npmjs.com name its workflow as a trusted publisher: `margelo/nitro-ui` with `hermes-linux.yml` for `nitro-hermes-linux-x64`, and with `hermes-windows.yml` for `nitro-hermes-windows64` ([trusted publishing](https://docs.npmjs.com/trusted-publishers)). Retries skip versions that are already published. Trusted publishing can't list staged versions, so a retry for a version that is still waiting fails and asks for its approval. A maintainer checks the exact version in npm's Staged Packages tab and approves it with 2FA ([npm staged publishing](https://docs.npmjs.com/staged-publishing/)). On an Apple Silicon Mac, `bun run release --publish` checks that the approved Linux and Windows versions are publicly installable, publishes the matching Mac package if needed, and then publishes the SDK. Ordinary SDK releases reuse the existing compiler versions. ### Cutting a release Prepare it on the Mac: ```sh bun run release --version ``` This updates the package versions and lockfile and writes `.release/*.tgz` with native sources, materialized headers and exact dependency versions, including the host compiler packages. Test the archives in a separate app, then land the version bump on `main`. The GitHub release groups Conventional Commits since the last release tag by type, with a bold area label for each commit scope. A scope like `renderer/list` puts the commit under a List subarea of Renderer. `chore` commits are left out. Commits marked with `!` or a `BREAKING CHANGE:` footer go under breaking changes. For upgrade notes specific to a release, add `scripts/release-notes/.md` in the version bump. To preview the notes: ```sh git fetch origin --tags bun run release --notes ``` Publish from a clean checkout of the landed release commit, logged in to npm as `hannojg` and to the GitHub CLI with release access: ```sh bun run release --publish ``` This publishes every package under npm's `latest` dist-tag, verifies the public checksums, then tags the commit and creates the GitHub release. Stable versions become the latest GitHub release and alphas are marked as prereleases. npm can accept an upload before it is installable, so the command checks pending versions every 30 seconds until all of them are public before moving on to GitHub. `bun run release --verify` runs a single availability and checksum check.