frontends/mobile, with a screen that lists products from your API. It does not get a hand-written client: forge generate writes the same typed hooks into it that the web frontend uses, from the same proto, so a new RPC reaches both apps on the next generate.
Before you begin
- A Forge Go project with an entity: Build a Go and React app. The examples use its
CatalogServiceandProduct. - Node.js and npm. To run the app on a phone, the Expo Go app or an emulator.
- Forge v1.6.1 or later in the project (
reliant forge --version).
1
Scaffold the app
terminal
Output (trimmed)
forge generate. What it wrote:2
Point TypeScript and Metro at the generated code
The generated protobuf code imports its neighbours as And in
./x_pb.js, and the hooks import @reliantlabs/forge-web-runtime/service-hooks through the package’s exports map. Expo’s defaults resolve neither, so give the app two settings. In frontends/mobile/tsconfig.json, add to compilerOptions:frontends/mobile/tsconfig.json
frontends/mobile/metro.config.js, just above module.exports = config;:frontends/mobile/metro.config.js
3
Call the API from a screen
Replace the placeholder screen with a product list:The hook is an ordinary TanStack Query hook, so
frontends/mobile/app/index.tsx
data is typed as ListProductsResponse, and useCreateProduct invalidates this list when a product is added.4
Check that it typechecks and bundles
terminal
Output (trimmed)
5
Run it against your dev API
Start the API with Scan the QR code with Expo Go. Every RPC requires sign-in by default, and the app sends no credentials yet, so the screen shows an
reliant forge env up dev and note its URL (api http://localhost:8085 in the summary). On a phone or emulator, localhost is the device itself, so point the app at an address the device can reach, such as your computer’s LAN address, and start Expo’s dev server from the app’s directory:terminal
unauthenticated error (missing Authorization header) until you wire a sign-in (below).6
Keep the app out of hosted deploys
The scaffold also adds the app to the staging and prod bundles in Then check that the env declares only your web frontend:
deploy/kcl/staging/main.k and deploy/kcl/prod/main.k. Reliant hosting serves web frontends; it does not build or serve a native app. Delete these lines from both files:deploy/kcl/prod/main.k
terminal
Output (trimmed)
What this does not do
- It does not ship the app to phones. Reliant hosting does not build, sign, host or distribute iOS or Android apps. Build and submit them with Expo’s own tools (EAS Build and Submit) or Xcode and Android Studio.
- It does not sign users in. The scaffold ships a mock session provider, so the app attaches no token. Implement
AuthProviderinsrc/lib/auth/provider.tsover your identity source, then callsetAuthTokenGetter(() => provider.getToken())inapp/_layout.tsx, as the comment there shows. Until then, only RPCs withauth_required: falseanswer the app. - It does not design the app. The scaffolded screen is a placeholder.
Troubleshooting
Cannot find module '@reliantlabs/forge-web-runtime/service-hooks' or its corresponding type declarations
Cannot find module '@reliantlabs/forge-web-runtime/service-hooks' or its corresponding type declarations
npm run typecheck is resolving with Expo’s default moduleResolution: node. Add the two compilerOptions from the second step.None of these files exist: * src/gen/forge/v1/forge_pb.js
None of these files exist: * src/gen/forge/v1/forge_pb.js
Metro cannot map the generated
.js import to the .ts file. Add the resolveRequest function from the second step to metro.config.js, then restart expo start.frontend_mobile.log: npm error Missing script: "dev"
frontend_mobile.log: npm error Missing script: "dev"
env up dev tries to start the app with npm run dev, which an Expo app does not have. The API is unaffected. Start the app yourself with npx expo start from frontends/mobile.Next steps
Add a custom RPC
Add an RPC; its hook appears in both frontends on the next generate.
Add sign-in with passkeys
Set up the identity your mobile sign-in will use.
Build the UI before the backend
Work on screens against mock data.
Adding features
Every scaffold forge offers, frontends included.