Skip to content
Preview: packages are not published yet.

Check the contract

Know what breaks the native app before you open the pull request. nuib check runs on every pull request, for the React team and CI. It never builds native code and needs no device. It runs five checks and reports every problem at once.

Check What it does
types Runs the project’s own TypeScript.
contract Reads every registerSurface call and its props.
diff Compares the contract with the previous manifest.
version Proposes the next version from the diff.
size Compares sizes per layer and per slice or ABI.

You add a required prop to a surface. Every native call must now pass it, so the change is breaking.

On the React side:

PointsHistory.tsx
export interface PointsHistoryProps {
userId: string
compact?: boolean
region: string // new, required
}
registerSurface<PointsHistoryProps>('PointsHistory', PointsHistory)

In the native app, in Swift:

// compiled against the previous version
PointsHistory.viewController(userId: "42")
// against the new one: does not compile,
// the call is missing `region`

In the terminal, with the manifest of the published 1.2.0 as the previous one and brownfield.version still 1.2.0:

$ bun run nuib check --against previous.json
nuib check: ShopReact 1.2.0 (<project>)
types ok (tsc --noEmit -p tsconfig.json --pretty false)
contract ok: 1 surfaces (PointsHistory), hash 476b6b5248d6377c
previous ShopReact 1.2.0 (release, nuib.manifest/6) from file <project>/previous.json
diff 1 change, needs a major bump
BREAKING prop-added-required PointsHistory.region: new required prop "region" on surface "PointsHistory": every call must pass it
engine same (Nitro UI version): same Nitro UI version; native module changes are only seen in the engine hash of a packaged manifest
version FAILED: 1.2.0 → configured 1.2.0, proposed 2.0.0 (major)
error: the contract breaks without a major version bump: configured 1.2.0, previous 1.2.0, needs at least 2.0.0
size skipped: size not checked: no packaged manifest (run nuib package first, or pass --manifest); nuib check never builds
result FAILED (exit 16: version)
error: "nuib" exited with code 16

The last line is Bun’s, not nuib’s. Set brownfield.version to 2.0.0 and the same run ends with version ok: 1.2.0 → configured 2.0.0, proposed 2.0.0 (major) and result ok (exit 0).

Besides the five checks, the report has an engine line: it says whether the engine changed since the previous manifest, by the engine hashes of a packaged manifest or else by the Nitro UI version installed in the project. A changed engine never fails the check; it adds a notice to look at the size.

A change is breaking when a native call site could stop compiling or change meaning. This is every kind of change nuib check reports.

Change in React Kind Impact
New surface surface-added additive
Surface removed surface-removed breaking
New optional prop, after every existing prop prop-added-optional additive
New optional prop before an existing prop prop-inserted-optional breaking
New required prop prop-added-required breaking
Prop removed or renamed prop-removed breaking
Prop type changed, for example string to number prop-type-changed breaking
Optional prop made required prop-made-required breaking
Required prop made optional prop-made-optional additive for a surface prop, breaking for a property of a nested object
Props reordered props-reordered breaking
Literal-union member added enum-value-added breaking
Literal-union member removed enum-value-removed breaking
Literal-union members reordered enum-values-reordered breaking
Type alias of an enum or object renamed type-renamed breaking
brownfield.name changed artifact-renamed breaking
ios.minimum raised ios-minimum-raised breaking
android.group or android.artifact changed android-coordinate-changed breaking
android.minSdk raised android-min-sdk-raised breaking
A platform section removed platform-removed breaking
Only internal code none patch
  • Any breaking change: major. While the major is 0, the minor is the breaking position: 0.4.0 goes to 0.5.0.
  • Any additive change: minor. While the major is 0: patch.
  • Otherwise: patch. A new engine does not change the level; it adds a size notice.

nuib publish runs the same check and refuses a contract break without the bump.

Exit code Meaning
0 Every check passed (warnings allowed)
1 Usage or configuration error, or a manifest that cannot be read
4 Type errors
8 Contract errors
16 Version policy
32 Size threshold

When several checks fail, the code is their sum: types and contract give 12.