React Native renderer (iOS & Android)
The React Native renderer (frontend/app/react-native, Expo SDK 57 / React Native 0.86, TypeScript)
turns any Mateu backend into a native iOS and Android app. It speaks the same
POST /mateu/v3/sync/{route} wire as the web renderers, so the backend needs no changes — one
server serves web, desktop and mobile at once. It is a fully supported renderer: every
component type of the wire has a native rendering (see the
coverage table), and CI fails the build if a
new wire type arrives without one.
For the architecture and the other native renderer see Desktop & Mobile.
1. Point it at a backend
Section titled “1. Point it at a backend”Three ways, from quickest to production:
| Situation | How the app finds its backend |
|---|---|
Local development (npm run web, Expo Go, emulator) | http://<dev host>:8594 — the host is the Expo dev server’s (hostUri, so a phone on your Wi-Fi reaches your laptop), the port is EXPO_PUBLIC_MATEU_BACKEND_PORT (default 8594, demo/demo-front-office) |
| Any build pointing at a fixed backend | EXPO_PUBLIC_MATEU_REGISTRY_URL + EXPO_PUBLIC_MATEU_APP_ID → the app registry |
| Store installables | the same two values, set in the EAS environment of the build profile (see store builds) |
A store installable is one of two build variants (MATEU_VARIANT): hub, the generic Mateu app
whose users add UIs themselves, or fixed, bound to one UI — a base URL (MATEU_FIXED_URL) or the
registry pair above — with no hub and none of its links. See
Hub or fixed.
cd frontend/app/react-nativenpm ciEXPO_PUBLIC_MATEU_BACKEND_PORT=8595 npm run web # demo-admin-panel on :8595, in a browsernpm start # QR code for Expo Go on a real phoneEXPO_PUBLIC_MATEU_ROUTE=/some/route boots straight into a route instead of the home screen; in
the browser build, ?route=/some/route on the page URL does the same without a rebuild.
In a browser (npm run web) the backend must allow the Expo origin. The page is served from
another origin than the backend, and Mateu’s CORS is off by default — without this the app stops
at “Can’t reach the server” and the browser console shows a CORS error:
java -jar target/demo-admin-panel-0.0.1-SNAPSHOT.jar --mateu.cors.allowed-origins=http://localhost:8081Expo Go, simulators and installables are not browsers: they need no CORS setting.
Live reload. Against a backend in development mode (mateu.dev=true — what the IDE’s Run Mateu
App (Live) starts), the app reads devEvents from the backend’s manifest and follows
/mateu/dev/events while the UI is open: a YAML edit under specs/ui, the reload the IDE fires after a
HotSwap, or a restarted backend re-renders the screen on display without restarting the app (values
typed and not saved are lost). A production backend names no event stream, so nothing is opened.
Details: Live reload.
2. The app registry
Section titled “2. The app registry”An installable carries only a registry URL and an app id. At boot it fetches
{registryUrl}/{appId}.json (or the URL with {appId} substituted) and gets everything else, so
retargeting a backend, changing launch parameters, forcing an upgrade or switching the identity
provider is a registry edit — not a store release:
{ "appId": "front-office", "baseUrl": "https://apps.example.com/front-office", "parameters": { "tenantId": "1111" }, "requiredRendererVersion": "1.0.0", "storeUrl": { "android": "https://play.google.com/…", "ios": "https://apps.apple.com/…" }, "auth": { "type": "oidc", "issuer": "https://login.example.com/realms/acme", "clientId": "mateu-mobile", "scopes": ["openid", "profile", "email", "offline_access"] }}parametersare seeded into theappStateof every request.requiredRendererVersiongates the boot of a registry-bound build: an older installable shows Update required, tries an over-the-air update (EAS Update) and falls back tostoreUrl. The hub (and a fixed build bound to a URL) checks the UI itself instead: its manifest’swireVersion/mateuVersionagainst the app, when a UI is added, opened and refreshed in the background — see the compatibility check. A refresh that finds the UI now needs a newer app never closes the screen on display: it says so above it, and the next open asks for the update.authturns sign-in on — next section.
3. Signing in to a secured backend
Section titled “3. Signing in to a secured backend”A secured Mateu backend resolves identity (@EyesOnly, @ReadOnlyUnless, @DisabledUnless,
HttpRequest roles) from a JWT sent as Authorization: Bearer <token>. The native renderer sends
it on every Mateu request (and on the AI chat), from a pluggable token provider:
- Built-in OIDC — declare
authin the registry entry (or, in dev,EXPO_PUBLIC_MATEU_OIDC_ISSUER/_CLIENT_ID/_SCOPES/_AUDIENCE). The app runs the Authorization Code flow with PKCE in the system browser (expo-auth-session), keeps the tokens in the keychain / keystore (expo-secure-store;localStorageon web), refreshes the access token before it expires, and shows a Sign in screen before the first screen ("loginOnStart": falsesigns in only when a request comes back 401). Sign out is at the bottom of the drawer, and on the hub’s top bar for a UI whose shell has no drawer (bottom tabs, no menu). Works with any standards-compliant provider (Keycloak, Entra ID, Auth0 — add"audience"—, Okta, Cognito…): it only needs the issuer’s discovery document. - Your own login — register any provider:
setTokenProvider({ getToken, refresh, login, logout })fromsrc/core/auth.ts.
Register these redirect URIs as allowed for the client at the identity provider:
mateu://auth (iOS/Android — the app’s scheme is mateu) and <web origin>/auth (expo web).
One client for the phone and the desktop app. In Keycloak (Clients ▸ Create client), the same public client serves both Mateu apps:
| Keycloak setting | Value | Why |
|---|---|---|
| Client authentication | Off (public client) | an installed app cannot keep a secret |
| Standard flow | On | the phone’s Authorization Code flow |
| OAuth 2.0 Device Authorization Grant | On | the desktop app signs in with the device flow |
| Direct access grants | Off | not used |
| Valid redirect URIs | mateu://auth (+ http://localhost:8081/* for expo web in development) | where the phone comes back |
| Web origins | + | expo web (development) |
| Advanced ▸ Proof Key for Code Exchange Code Challenge Method | S256 | both apps send a PKCE challenge — the desktop’s device request too |
The UI’s manifest names the provider (mateu.mobile.oidc.issuer / client-id, or the
MATEU_MOBILE_OIDC_* environment variables); the issuer must be https — plain http is accepted
only by development builds, for a provider on your own machine. Validating the token the apps send
is the host application’s job (a Spring/Quarkus/… resource server, or your FastAPI/ASP.NET auth):
Mateu takes the roles from what the framework authenticated.
Session expiry follows the web renderers’ contract: a 401 gives the app one chance to
re-authenticate — an explicit onSessionExpired(handler) (src/core/sessionGuard.ts) wins;
otherwise the provider refreshes silently, then prompts — and the original request is retried
once, so a half-filled form survives. Concurrent 401s share a single re-authentication.
Every installation also sends its own X-Session-Id (a random UUID created on first launch and
kept in secure storage), so two devices never share a server-side session.
4. Store builds
Section titled “4. Store builds”Builds go through EAS (npx eas-cli login once).
eas.json has three profiles; each maps to an EAS environment and an EAS Update channel
of the same name:
| Profile | Use | Network | App id |
|---|---|---|---|
development | internal APK against a LAN backend | cleartext http allowed (Android usesCleartextTraffic, iOS local networking) | io.mateu.app.dev |
preview | internal APK / ad-hoc for QA | https only | io.mateu.app |
production | Play Store .aab / App Store .ipa | https only | io.mateu.app |
# registry coordinates per environment — nothing environment-specific is committednpx eas-cli env:create --environment preview --name EXPO_PUBLIC_MATEU_REGISTRY_URL --value https://registry.example.comnpx eas-cli env:create --environment preview --name EXPO_PUBLIC_MATEU_APP_ID --value front-office
npm run build:apk # preview APKnpm run build:android # production .aabnpm run build:ios # production .ipanpm run submit:android # Play Store, internal tracknpm run submit:ios # App Store ConnectStore credentials are never in the repository. Upload them once to EAS
(npx eas-cli credentials: the Play service-account JSON and the App Store Connect API key), or
provide them on the submitting machine (EXPO_ASC_API_KEY_PATH, EXPO_ASC_KEY_ID,
EXPO_ASC_ISSUER_ID). Over-the-air updates are published by the ota job of
mobile.yml when a release is PUBLISHED (with EXPO_TOKEN set) — never on a manual re-run of an
older tag, which would push old JS over the newer release; npx eas-cli update --channel production
does the same by hand. runtimeVersion follows the app version, so an update only reaches binaries
it is compatible with — bump expo.version whenever a release changes native dependencies. The camera permission is the only
runtime permission requested on its own (for @PhotoCapture); the microphone is explicitly not. An
app with @App(osNotifications = true) also offers “Notify me on this device”, which asks for the
notification permission only from that tap. Those notifications are local, so a suspended or closed
app posts none: see what reaches the device.
5. Look and theming
Section titled “5. Look and theming”The app is drawn with Material Design 3 through React Native Paper
(MIT): top app bar, navigation drawer, filled / tonal / outlined / text buttons, outlined text
fields with the label in the outline, switches, checkboxes, segmented buttons for short tab
strips, cards, chips, dialogs, bottom sheets, snackbars and FABs. Icons come from
@expo/vector-icons (MIT, Material Community Icons). Everything is pure JavaScript, so it keeps
working in Expo Go.
- Light or dark follows the device. When the app declares
@App(themeToggle = true), the sun/moon button in the top bar switches the whole app for the session. - The primary colour is the app’s
@App(accentColor)when it is a hex colour (#0B6E4F); without one, a neutral blue. The accent is adjusted until it reads: darkened in light mode until white text reaches WCAG AA on it, lightened in dark mode until it reads as text on the dark surface. Red stays reserved for errors and destructive actions. - Buttons follow the wire’s
buttonStyle:primary→ filled,secondary→ tonal,tertiary→ text, anything else → outlined; acolor: "error"action (Delete) is painted in the error colour. - Listings on a phone are Material list items: the first column is the headline, the other
columns the supporting text, and a status column (
@Status,GridColumn.tones) is a chip coloured by its tone; a true boolean column shows as a chip with its label. Rows use Material’s three-line density (88dp). - The create action of a CRUD listing (its
Newbutton) is an extended FAB (”+ New”) at the bottom right, above the pagination bar and above the app’s assistant FAB; the listing’s other toolbar actions (bulk actions, Delete) stay in the action row. - Phones (window narrower than 600dp): every form section lays out in one column, whatever
its
@Section(columns = …)or@FormLayout(columns = …)says — two fields side by side are too narrow for their values. Tablets keep the declared columns. A@WizardProgress(RAIL)wizard shows its step rail above the form, collapsed to one line (“Step 2 of 4 · Account type”) with a linear progress bar, instead of beside it.
The tokens live in src/theme.ts (both schemes, contrast-checked by theme.test.ts); the Paper
theme is built from them in src/ui/MateuTheme.tsx, and the shared Material primitives (button,
status chip, checkbox, outlined field and picker trigger) are in src/ui/controls.tsx. A host app
that needs another brand changes the tokens there.
6. Compatibility
Section titled “6. Compatibility”The app declares the oldest wire it supports (MIN_WIRE_VERSION = "3.0",
src/core/wireVersion.ts). Every response carries wireVersion: a server speaking another major
version (or an older minor) gets a one-time Version mismatch warning instead of screens that
silently render wrong; a newer minor is fine (the wire is additive within a major).
7. Checks
Section titled “7. Checks”npm test # unit tests (node --test)npm run typecheck # tsc --noEmitnpm run parity # every wire component type has a native renderer; parity.md in syncnode scripts/wire-fixture-server.mjs 18600 # a page of rarely-used component types, for eyeballingRequest and response bodies are logged to the console only in development builds (__DEV__).