The mobile app
The React + Vite frontend as an Android and iOS app with Capacitor, with an update notice and a demo build.
pnpm dlx @clubedge/create-clubedge-app my-app --framework vite --api hono --shell capacitor--shell capacitor packages the React + Vite frontend as an Android and iOS app with Capacitor 8, in apps/shell. The app's pages load from the device: they are the web app, built in Vite's app mode, and they call the API through your deployed website. It needs CLI 0.42.0 or newer (Starter v0.27.0). For an app with native screens of its own, see The native app (--mobile expo); a project can have both.
Try the Starter's app on an Android phone: download clubedge-demo.apk from the latest Starter release and open it, allowing installs from unknown sources when Android asks. It is the app's demo build, with sample data that stays on the phone, no account, and no server behind it. iPhones install apps only from the App Store or TestFlight, so there is no file for them.
Choose it
A shell packages a frontend's static files, so --shell capacitor needs --framework vite, which needs its API, --api hono or --api fastapi. Next.js and TanStack Start render their pages on their own server, so they can't be packaged, and the CLI refuses them:
Next.js renders pages on its server, so Capacitor cannot package it: choose a frontend, or --shell none.Interactive runs ask Package the web app as a mobile app? after the frontend and its API, with Capacitor and None, the default. In the builder, the Mobile app row appears once React + Vite is picked. The project's package.json records the choice in "apps", as "shell": "capacitor".
A project created without it can add it later, and drop it again, with CLI 0.46.0 or newer: pnpm clubedge add shell capacitor, or pnpm clubedge remove shell (Change a project).
What you get
apps/shell: the app, package@clubedge/shell.capacitor.config.tssets its id and name,scripts/build.mjsbuilds the web app for it and copies the build into the native projects, and.env.localholdsWEB_URL.android/andios/appear on the first build.packages/mobile: the app's own code, which the web app loads only in its build for the app: the session's storage on the device, the app's version, the update notice, and the demo's fakes. The website's build has no Capacitor.apps/web/dist-app: the web app's build for the app. Git ignores it.
Requirements
- Android Studio 2025.2.1 or newer, for Android. It brings the Java 21 that Capacitor 8 builds with.
- A Mac with Xcode 26 or newer, for iOS. The iOS project uses Swift Package Manager rather than CocoaPods.
Capacitor's environment setup has the details.
Set it up
Set the app's id
In apps/shell/capacitor.config.ts, replace the generated com.example.<project> with a reverse-domain id you own, such as com.yourcompany.app. It becomes permanent once the Android and iOS projects exist and a store lists the app, so set it before the first build. The app's name comes from apps/web/src/config/site.json.
Point it at your website
Set WEB_URL to the website's public https:// address: where the React + Vite frontend is deployed. The app sends its session there, so the build refuses any other scheme, a path, or a query.
WEB_URL=https://app.example.comBuild and open it
pnpm --filter @clubedge/shell android # or ios, on a MacIt builds the web app for the app, creates apps/shell/android (or apps/shell/ios) on the first run, copies the build into it, and opens Android Studio (or Xcode), where you run the app on a device or an emulator. Commit android/ and ios/: from then on they are your app's own, with its icons, permissions, and signing settings.
Commands
| Command | What it does |
|---|---|
pnpm --filter @clubedge/shell android | Build the app for Android and open it in Android Studio. The first run creates apps/shell/android. |
pnpm --filter @clubedge/shell ios | The same for iOS and Xcode, on a Mac. The first run creates apps/shell/ios. |
pnpm --filter @clubedge/shell sync | Copy a new build of the web app into the native projects. |
Add --demo to any of them for the demo. After changing the web app, run sync. Release builds and store listings are made in Android Studio and Xcode, as Capacitor's guides for Google Play and the App Store describe.
Live reload
To see changes on a device as you make them, the app can load its pages from your computer's dev server instead. After a first android (or ios) build, start the web app in app mode, then run the app on a device or an emulator on the same network:
pnpm --filter @clubedge/web dev --mode app
pnpm --filter @clubedge/shell exec cap run android --live-reloadThe app then loads http://<your computer's address>:3000; change it with --host and --port, and use ios for iOS. With Better Auth, add that address to MOBILE_ORIGINS in apps/web/.env.local first, so Better Auth accepts the app's sign-in. Ctrl+C stops it. The installed app keeps loading its pages from your computer until you install a normal build again.
How it differs from the website
- Its origins. Its pages load from
https://localhoston Android andcapacitor://localhoston iOS. The website's server answers these origins' calls to/apiwith CORS headers: they are itsMOBILE_ORIGINS,capacitor://localhost,https://localhostby default, which you only set to change them. - Its session. The website's cookies never reach the app, so it keeps its session in the device's storage, private to the app, and sends it with each call.
- Emailed links, such as sign-up confirmations and password resets, open the website, never the app. After confirming an address, sign in again in the app.
- No payments. App stores require their own in-app purchases for digital goods, so the app has no billing card: subscriptions stay on the website.
- Its settings. Its build reads
apps/web/.env.localtoo, and the settings inapps/shell/.env.localwin. Give it the deployed website's publicVITE_*settings where development uses others.
Sign-in
Supabase keeps the app's session in the device's storage. With --infra supabase, the local Supabase runs on your computer, out of the device's reach: set your Supabase project's VITE_SUPABASE_URL and VITE_SUPABASE_PUBLISHABLE_KEY in apps/shell/.env.local.
Updates
An installed app keeps the version it shipped with, often for months. It asks the API's GET /api/app-version which versions the API serves, an answer that is never cached, and compares its own. It asks when it starts, and from Starter v0.29.0 also when it comes back to the foreground (at most every 15 minutes) and whenever the API refuses its version (Apps the API refuses):
- Below
APP_MINIMUM_VERSION, it shows Update required, a screen that keeps the app closed, with an Update button that opensAPP_UPDATE_URLin the phone's browser. From Starter v0.29.0, the app remembers it, so it holds when the app next starts offline, until it is updated. - Below
APP_NEXT_MINIMUM_VERSION(Starter v0.29.0 or newer), a notice above the page says the date the app stops working, with the same button. Not now hides it until the next day. - Below
APP_LATEST_VERSIONonly, a notice offers the update, and Not now hides it until a newer version is out. - When the API can't be reached, or doesn't know
/api/app-versionyet, nothing new shows: a remembered Update required still holds, and otherwise the app works as usual.
Set them in apps/api/.env.local, or in the API's environment in production. Each is null until set:
| Variable | Meaning |
|---|---|
APP_MINIMUM_VERSION | The oldest app version the API still serves. |
APP_LATEST_VERSION | The newest released version. It can't be older than the minimum. |
APP_UPDATE_URL | Where to get the update: an https:// link to the store listing or a download page. |
APP_NEXT_MINIMUM_VERSION, APP_NEXT_MINIMUM_VERSION_FROM | A minimum announced for a date, such as 2026-11-01T00:00:00Z, which the API requires from then. Starter v0.29.0 or newer. |
From Starter v0.29.0, each can be set for one platform with _IOS or _ANDROID, such as APP_UPDATE_URL_IOS: see Apps installed on phones.
Versions are MAJOR.MINOR.PATCH, such as 1.4.0. Other values fail the request rather than reach the apps, and pnpm check:env lists them before a deploy.
From Starter v0.30.0, the app's version is version in apps/shell/version.json, which each build writes into both native projects: see Store releases. Before, it was versionName in apps/shell/android/app/build.gradle and MARKETING_VERSION in Xcode.
Installed apps also keep calling the API contract they shipped with, so CI fails a pull request that breaks it: see Apps installed on phones.
Store releases
From Starter v0.30.0, the app's version, which the stores show and the update notice compares, is in apps/shell/version.json. Each build writes it into both native projects, with the build number the stores order builds by, made from it: 1.4.2 is build 1004002. A build never takes a native project's version back: after upgrading from an earlier Starter, whose native projects held the version, the first build stops and names the set-version command that carries it over. Set a newer one for each release:
pnpm --filter @clubedge/shell set-version 1.5.0pnpm --filter @clubedge/shell release android (or ios) builds the release, signed, and copies it to apps/shell/release/: an App Bundle for Google Play, which Gradle builds and the JDK's jarsigner signs, or an IPA for the App Store, which Capacitor builds and Xcode signs. It signs with the settings in apps/shell/.env.local:
| Platform | Settings |
|---|---|
| Android | Your upload key: ANDROID_KEYSTORE_PATH, ANDROID_KEYSTORE_PASSWORD, ANDROID_KEY_ALIAS, and ANDROID_KEY_PASSWORD. Make the keystore once with keytool -genkeypair -v -keystore upload.keystore -alias upload -keyalg RSA -keysize 2048 -validity 10000, and keep it outside the repository. |
| iOS, on a Mac | IOS_TEAM_ID, for Xcode's automatic signing; to sign manually, IOS_SIGNING_CERTIFICATE and IOS_PROVISIONING_PROFILE too. |
The Mobile app release workflow (.github/workflows/shell-release.yml, run from the Actions tab) does the same on GitHub's runners, keeps each build as the run's artifact, and can upload the iOS build to TestFlight. It builds for the website in the WEB_URL repository variable, with the signing settings as repository secrets: the keystore and the certificate as base64 (ANDROID_KEYSTORE_BASE64, IOS_CERTIFICATE_BASE64, IOS_PROVISIONING_PROFILE_BASE64), and an App Store Connect API key for TestFlight. The project's SETUP.md lists each one.
Google Play takes an app's first upload in its console. Once the stores publish a release, set the API's APP_LATEST_VERSION to it (Updates).
Push notifications
With --push native (Starter v0.30.0 or newer), the app's settings page gets a Notifications card: a switch, and a test notification. The API sends straight to FCM and APNs, and each build sets push up in the native projects. See Push notifications.
The demo
pnpm --filter @clubedge/shell android --demo # or ios --demoThe demo build is for trying the app, or for store screenshots: it needs no server and no WEB_URL. Sign-in and the API answer from memory on the device, with fakes from packages/mobile/src/demo:
- Any email and password sign in a demo user; sign-up and password reset say they are off.
- The settings work until the app closes, and deleting the account signs out.
- Other calls answer as an API with nothing set up would, and routes the demo leaves out answer 404, as for a module the project doesn't have.
- A banner says it is a demo, with sample data that stays on the device.
Builds without --demo contain none of it. The demo replaces the app's build in the native project, so run pnpm --filter @clubedge/shell sync before building a release.
Each Starter release from v0.27.0 attaches the Starter's own demo for Android, clubedge-demo.apk. It is built from a project with React + Vite, Hono, Better Auth, file storage, and background jobs, whose sample job runs on the phone.
CI
The project's CI builds a debug APK on each pull request and push to main, and keeps it for 7 days as the run's android-debug artifact, to install on a device. Set a WEB_URL repository variable so that it calls your website; without one, it calls https://example.com.
Limits
- Only the React + Vite frontend can be packaged, with either API.
- The app needs the deployed website: it calls the API through it, and emailed links open it. The app runs no server, so
pnpm clubedge deploydeploys the website and the API and leaves it out. - No in-app payments: subscriptions stay on the website.
- The stores' accounts, listings, and review are yours. The builds and their signing are set up: see Store releases.
When the app can't reach the API
Check that WEB_URL in apps/shell/.env.local is the deployed website's address, and that the website's MOBILE_ORIGINS lists the app's origins. Then run pnpm --filter @clubedge/shell sync again.
How is this guide?