Mobile appsNo. 20
Three apps from one Expo codebase: customer, driver and manager
How one Expo folder builds three store apps for a restaurant: a config that picks the app, a route group each, what to share and what not to, local builds, and the traps.


In this article
A restaurant that sells online without paying a delivery app needs three phone apps. The customer orders and pays. The driver sees the orders assigned to him and shares his position on the way. The manager accepts or declines each incoming order and assigns a driver.
That is three icons on three home screens, three listings in the store, three different sets of permissions. In FinyX-ERP, my accounting and point-of-sale product, the three apps are one folder. One config file reads an environment variable at build time and decides which app comes out. A new restaurant is a brand file and three build commands. Not one screen changes.
The interesting part is not the sharing. It is the line between what the three apps share and what they must not: who signs in and how, what each one asks of the phone, and who decides what each person may do.
By the end you will be able to set up one Expo project that builds several store apps: the config that picks the app, a route group per app behind a single entry, the code worth sharing and the code that must stay apart, Android builds and updates on your own machine, and the traps I hit on the way.
In short
- One
app.config.tsreadsAPP_VARIANTand a brand file at build time, and returns a different name, package, icon, splash, permissions and version for each app. - Each app is an Expo Router route group behind one entry screen. The screens belong to one app; the API client, the session, the theme and the map belong to all three.
- A screen inside the bundle is not a permission. The server checks every request, so the customer's app can carry the manager's screens without danger.
3
store apps from one folder
1
config file that picks the app
33
API paths in the one contract they share
0
screens changed for a new restaurant
One config file decides which app you are building
Expo lets the app's configuration be code. app.config.ts is a function that runs on your machine when you build, and returns the name, the Android package, the icons and everything else the store sees. That function is where one codebase becomes three apps.
It reads two inputs. APP_VARIANT says which app: customer, driver or manager. FINYX_BRAND names a file in brands/ that holds the restaurant's identity: its Arabic and English names, two colours, a font, a corner style, the prefix for its package names, and its position on the map, where every driver starts.
type Variant = 'customer' | 'driver' | 'manager';
const VARIANTS: Record<Variant, { suffix: string; labelAr: string }> = {
customer: { suffix: '', labelAr: '' },
driver: { suffix: 'driver', labelAr: 'السائق' },
manager: { suffix: 'manager', labelAr: 'الإدارة' },
};
export default ({ config }: ConfigContext): ExpoConfig => {
const variant = (process.env.APP_VARIANT ?? 'customer') as Variant;
if (!(variant in VARIANTS)) throw new Error(`Unknown APP_VARIANT: ${variant}`);
const brand = readBrand(process.env.FINYX_BRAND ?? SAMPLE_BRAND); // brands/<slug>.json
const meta = VARIANTS[variant];
const iconDirectory = `./assets/brand/${brand.slug}/${variant}`;
return {
...config,
name: meta.labelAr ? `${brand.nameAr} — ${meta.labelAr}` : brand.nameAr,
slug: `finyx-${brand.slug}-${variant}`,
scheme: `finyx-${brand.slug}-${variant}`,
// Version and build number come from the build: Play refuses an upload whose number is not higher.
version: process.env.FINYX_APP_VERSION ?? '1.0.0',
icon: `${iconDirectory}/icon.png`,
android: {
package: meta.suffix ? `${brand.packagePrefix}.${meta.suffix}` : brand.packagePrefix,
versionCode: Number(process.env.FINYX_ANDROID_VERSION_CODE ?? '1'),
// permissions, adaptive icon and splash differ per app: see below
},
// apiUrl and mapTiles come from FINYX_API_URL and FINYX_MAP_TILES
extra: { variant, apiUrl, brand, restaurantLocation: brand.location, mapTiles },
};
};The customer app carries the restaurant's name; the staff apps add a label to it. Each app gets its own package, which makes it a separate store listing, and its own URL scheme, so a link meant for the driver app never opens the customer's. Icons and splash screens live in one folder per brand and per app.
The extra block is how the build talks to the running app. The app reads it once through expo-constants, and refuses to start without it, because an app that does not know which app it is should not run:
const extra = Constants.expoConfig?.extra as Extra | undefined;
if (!extra) throw new Error('App settings are missing: started without app.config.');
/** Which of the three apps this is, as it was built. */
export const variant: AppVariant = extra.variant;
export const apiUrl = extra.apiUrl;
export const brandIdentity = extra.brand;Expo's own documentation uses the same APP_VARIANT pattern to install a development build and a preview build of one app side by side (multiple app variants). Here the variants are three products.
| App | APP_VARIANT |
Package | Who signs in, and how |
|---|---|---|---|
| Ordering | customer |
<prefix> |
Customers, with a phone number and a six-digit code sent by message |
| Driver | driver |
<prefix>.driver |
Staff with the driver-app permission, with the same username and password as the till |
| Manager | manager |
<prefix>.manager |
Staff with the restaurant permission, the same way |
One route group per app, and one door
Expo Router turns files into screens: every file under src/app is a route. A folder whose name is in parentheses is a route group, which organises screens without adding anything to the path. Each app gets one group.
src/app/
_layout.tsx one root: query client, session, splash screen
index.tsx the door: sends each build to its own group
(customer)/ menu, item, cart, checkout, payment, orders, account
(driver)/ sign-in, my deliveries, one delivery, account
(manager)/ sign-in, today, incoming, orders, drivers, accountThe door is the whole routing logic, and it fits on one screen:
/** Every app starts at its own door: the customer at the menu, staff at sign-in until they have signed in. */
export default function Entry() {
const { session, ready } = useSession();
if (!ready) return null;
if (variant === 'customer') return <Redirect href="/(customer)/(tabs)" />;
if (variant === 'driver') return <Redirect href={session ? '/(driver)/(tabs)' : '/(driver)/sign-in'} />;
return <Redirect href={session ? '/(manager)/(tabs)' : '/(manager)/sign-in'} />;
}ready matters more than it looks. The session is read from the phone's secure store, which takes a moment, and until it is read the entry renders nothing. The root layout keeps the splash screen up for exactly that moment, so a manager who signed in yesterday never sees the sign-in screen flash past.
With typed routes switched on, a misspelled path in a Redirect fails the type check, not the driver.
Share the plumbing, not the screens
I counted the lines in the committed version. Most of the code a driver touches is not in the driver's folder.
The customer app is the largest because ordering is the hardest flow: options and sizes, a cart, a pin on the map, a choice between paying now and paying on delivery. The driver app is small because a driver needs little: his orders, the way there, two buttons.
Below the screens, sharing follows how many apps need a thing, not how general it looks:
| Shared by | What |
|---|---|
| All three | The typed API client, the session, the config, the theme, number and time formats, the map, buttons, headers, loading and error states, the tab bar |
| Two | Staff sign-in and the staff account screen (driver and manager), payment labels (customer and manager) |
| One | The cart and the order timeline (customer), the delivery card and the location sender (driver), the hourly sales chart (manager) |


One contract, generated once
The restaurant's server publishes an OpenAPI contract, a machine-readable description of every path and every field. A web package generates TypeScript types from it once, and the web store uses them. A small script copies the generated file, and the code that turns a brand into colours, into the app:
const copies = [
[path.join(web, 'api-client', 'src', 'schema.ts'), path.join(root, 'src', 'shared', 'api', 'schema.ts')],
[path.join(web, 'tokens', 'src', 'color.ts'), path.join(root, 'src', 'shared', 'brand', 'color.ts')],
[path.join(web, 'tokens', 'src', 'brand.ts'), path.join(root, 'src', 'shared', 'brand', 'brand.ts')],
];Every copy gets a header that says it is generated and must not be edited. The client is openapi-fetch typed by that contract, so a path or a field that does not exist is a compile error, not an error in a customer's hand. The contract has 33 paths and 44 schemas, and all three apps compile against the same file.
The brand works the same way. The app's colours are derived from the brand file by the same function the website uses. A brand colour that white text cannot sit on gets dark ink instead, a colour too light to write with on white is darkened by the least amount that makes it readable, and each correction is reported as a warning. A restaurant with a pale yellow logo still gets buttons you can read, and no screen holds a colour of its own.
Each app keeps its own rhythm
The data hooks are shared in shape and different in pace. They all use TanStack Query, a library that fetches, caches and refreshes server data, with one rule for every app: a refusal from the server is final, and only a failure to reach it is retried.
// A refusal with a written reason will not change on retry; a network fault is retried twice.
retry: (failures, error) => !(error instanceof ApiError && error.status >= 400) && failures < 2,What differs is how often each screen asks:
| Screen | Asks the server every |
|---|---|
| Customer: tracking an order | 8 seconds, and stops when the order is final |
| Driver: my deliveries | 10 seconds |
| Manager: incoming orders | 10 seconds |
| Manager: live orders, drivers | 15 seconds |
| Manager: the day's numbers | 30 seconds |
A screen in the bundle is not a permission
Expo Router bundles every file under src/app. So the customer's app carries the manager's screens in its JavaScript, and the driver's app carries the checkout. Nothing routes there, but the code is in the package.
That is safe for one reason only: a screen decides nothing. Every driver request is checked on the server, in the service that does the work, not in the endpoint and not in the app:
public async Task<DriverDelivery> PickUpAsync(int orderId, CancellationToken cancellationToken = default)
{
_authorizationContext.DemandPermission(PermissionCodes.Restaurant.DriverApp);
// … then only an order assigned to this driver, and only when the kitchen marked it ready
}The app checks too, for a different reason. After a staff member signs in, each staff app looks for its own permission in the answer, and says so on the sign-in screen if it is missing, instead of letting him into screens that will come up empty. That check is a courtesy. The one on the server is the rule.
Sessions stay apart as well. The token lives in the phone's encrypted store, not in ordinary app storage, so copying the app's files does not reveal it, and its key carries the app's name, such as finyx.session.driver. On the server, a customer's token and a staff member's token are checked by two different authentication schemes.
Watch out
If the only thing keeping a customer out of the manager's screens is that his app does not link to them, you do not have three apps. You have one app with hidden doors. Put the rule where the data changes.
What each app asks of the phone
The store sees each app's permissions separately, and so does the person installing it. The config gives each app only what it uses:
const usesLocation = variant === 'customer' || variant === 'driver';
android: {
// The customer, to place the pin at his door. The driver, so the customer can watch him come.
permissions: usesLocation ? ['android.permission.ACCESS_COARSE_LOCATION', 'android.permission.ACCESS_FINE_LOCATION'] : [],
// Libraries add these for development tools; a published app does not need them, and Play asks about each one.
blockedPermissions: [
'android.permission.SYSTEM_ALERT_WINDOW',
'android.permission.READ_EXTERNAL_STORAGE',
'android.permission.WRITE_EXTERNAL_STORAGE',
...(usesLocation ? [] : ['android.permission.ACCESS_FINE_LOCATION', 'android.permission.ACCESS_COARSE_LOCATION']),
],
},The manager app blocks location outright: the location library is part of every build and would otherwise bring its permissions along. The text the phone shows when it asks also differs per app: the customer reads that his position brings the order to his door, the driver that his position lets the customer follow him on the map. I wrote about what these permissions give an app in why apps ask for your photos and location.
The driver's position is sent only while the app is open, every 15 seconds or every 25 metres, whichever comes first. Tracking in the background needs a wider permission and a review by Google Play, so it waits until a restaurant asks for it.
A few more things differ by design. The customer app's icon background and splash screen take the restaurant's colour, and the two staff apps use a dark surface. And all three are Arabic only, with the layout forced right to left whatever language the phone is set to.
Builds and updates without EAS
EAS, Expo's cloud service, can build, sign and submit apps. These builds run on my machine instead, with Gradle, Android's build tool. The android/ folder is generated from the config on every build and never committed, so the config stays the only source of truth.
- Pick the appAPP_VARIANT, FINYX_BRAND, the version and the build number
- app.config.tsname, package, icons, permissions
- expo prebuildgenerates android/ from the config
- gradlew bundleReleasean .aab signed with the upload key
- Play ConsoleGoogle signs what phones install with the app's own key
$env:APP_VARIANT = 'driver' # customer, driver or manager
$env:FINYX_BRAND = '<restaurant>'
$env:FINYX_API_URL = 'https://<restaurant server>'
$env:FINYX_APP_VERSION = '1.0.1'
$env:FINYX_ANDROID_VERSION_CODE = '2' # higher than anything uploaded for this app
npx expo prebuild --platform android --clean
cd android; .\gradlew bundleReleaseSigning needs one change to the generated Gradle file, and generated files must not be edited by hand. So a config plugin, a small function Expo runs during prebuild, makes the change every time. Two details make it safe to rerun and impossible to misapply:
const MARKER = '// finyx-upload-signing';
module.exports = function withUploadSigning(config) {
return withAppBuildGradle(config, (gradle) => {
let contents = gradle.modResults.contents;
if (contents.includes(MARKER)) return gradle; // already applied
const debugBlock = /(signingConfigs\s*\{\s*debug\s*\{[^}]*\})/;
if (!debugBlock.test(contents)) {
throw new Error('with-upload-signing: signingConfigs.debug not found in app/build.gradle; the Expo template changed.');
}
contents = contents.replace(debugBlock, `$1${SIGNING_CONFIG}`);
// … and the release build type takes the upload key when one is configured
gradle.modResults.contents = contents;
return gradle;
});
};The key and its two passwords never enter the repository: Gradle reads them at build time from the user's own Gradle properties or the environment. Without them, the release build is signed with the debug key and Gradle warns that Google Play will refuse it, so an emulator build still works and a wrong upload fails loudly. The script that creates the upload key refuses to put it inside the repository, and refuses to overwrite an existing one, because a new key cannot sign an update to an app uploaded with the old one.
Play App Signing removes the scariest failure. Google keeps the key that signs what phones install, and the key I hold only proves an upload is mine. If it is ever lost, Google can reset it.
Two costs come with this setup, and both are worth stating. There are no over-the-air updates: Expo's update library is not installed, so even a one-line change is a new build, a higher build number and three uploads, one per app. And these are Android builds; the config has no iOS section yet.
Tip
Give every app its own build number counter. Three apps from one folder are still three listings, and Play compares each upload only with that app's own history.
The traps I hit on the way
Each one is handled in the code today, and each one is easy to hit again.
- A "#" in the folder path. My repository lives under
C# App, and Gradle breaks on the#. Asubstdrive letter does not help: Node resolves it back to the real path, the code generator sees two different roots and stops. The fix is to build from a copy in a short path without the character, which also keeps the native C++ build under Windows' 260-character path limit. - Mirroring
node_modules. After the first build, copying the project over withrobocopy /MIRerases what Gradle built insidenode_modules, and the C++ build starts from zero. Now only the source, scripts, plugins and top-level files are copied, and switching apps usesexpo prebuild --no-installwithout--clean, so Gradle's caches survive. - Metro and
.tsin imports. The web build acceptsfrom './color.ts', and Metro, React Native's bundler, does not. The sync script strips the extension as it copies. - An explicit tab bar height. Setting it cancels the library's own space for the bottom edge of the screen, and Android's navigation bar covered the tab labels. The inset is now added back by hand.
- A ref does not redraw. The driver's own marker never appeared on his map, because his position was kept in a ref. It moved into state.
- Payments inside a WebView. Moyasar's card form runs in a WebView, where Apple Pay does not work, so the app offers cards and mada, the Saudi debit network. React Native's
URLhas nosearchParams, so the payment id is read from the return address with a regular expression. - Map tiles. The map is OpenStreetMap through Leaflet, bundled inside the app rather than loaded from a CDN. The public tile servers are another matter: OpenStreetMap's tile policy warns that heavy use can be blocked, so the tile address is a build variable, and production passes a paid provider or a tile server of its own.
The checklist
- Put every difference between the apps in
app.config.ts, driven by environment variables. No screen should know which build it is in, except the entry. - Give each app its own package, URL scheme, icon folder and build number.
- Use one route group per app and one entry screen that sends each build to its door.
- Share by need: the API client, the session and the design system everywhere, the rest only where two apps truly use it.
- Generate the API types once from the server's contract, copy them, and mark the copy as generated.
- Derive colours from the brand with contrast checks, and keep colours out of screens.
- Assume every screen ships in every app. Check every permission on the server.
- Ask each app's permissions separately, and block what libraries add for development.
- Keep the upload key out of the repository, fail loudly without it, and turn on Play App Signing.
- Write down what the setup does not do yet, such as over-the-air updates or iOS, before someone assumes it does.
Three apps are one product with three doors. Keep the doors in one file, and keep the locks on the server.
This is how I build mobile apps, and FinyX's apps are part of the FinyX-ERP case study.
Share







