Multi-platform starter
What you'll have afterwards:
- A web app on
http://localhost:3000with sign-up, sign-in, account pages and an admin area, signed in with theadminrole. - A mobile app on
http://localhost:3001, and on iOS and Android, that signs in at that web app. - A desktop app on
http://localhost:3002, and on macOS, Windows and Linux, that signs in at the same web app, as a single-page app (SPA) or offline with its own server. - One account for all three: the web app's users sign in to both apps.
Use this starter when one product ships on the web, on phones and on the desktop. It is the standalone mobile starter plus the app of the desktop starter, wired together:
apps/webhas sign-up and sign-in, a/dashboardusers land on,/accountpages and an admin area with user management. With OAuth Server it is also the issuer and the API of the other two apps.apps/mobileis a Capacitor app on Mobile. It signs in atapps/webwith Auth in client mode and calls/api/mewith its access token.apps/desktopis a Tauri v2 app on Desktop. It signs in atapps/webin either mode, picked byDESKTOP_MODEinapps/desktop/.env:
| Mode | What ships in the app | Sign-in at apps/web |
|---|---|---|
remote (default) | A static Nuxt 4 SPA that calls apps/web's API | Auth in client mode, client desktop: the system browser, and the redirect back as a deep link |
local | The whole app, with its server, Users and SQLite, compiled with Bun into a sidecar on 127.0.0.1 (Local mode) | Auth in server mode with the browser handoff, client desktop-local, then a cookie session on the app's own server |
apps/web reads the client ids and redirect URIs of both apps from
apps/mobile/identity.ts and apps/desktop/identity.ts.Prerequisites
The tools in Requirements. The native builds need more, but pnpm dev runs
all three apps in a browser without them:
| Tool | For |
|---|---|
| Xcode | iOS: a recent Xcode with an iOS simulator. |
| Android Studio | Android: a Java Development Kit (JDK) and the Android SDK. |
| Rust and your OS's prerequisites | The desktop app: cargo from rustup.rs, and the Xcode Command Line Tools, the C++ Build Tools and WebView2, or WebKitGTK 4.1. See Desktop prerequisites. |
| Bun | The desktop app's local mode, to compile its server: bun.sh. |
1. Create the project
Copy .starters/multi-platform with
pnpm create frigear-app (CLI) or with giget.
pnpm create frigear-app also runs pnpm install and pnpm prepare:env:
pnpm create frigear-app my-app --platform web,mobile,desktop
cd my-app
git init
pnpx giget@latest gh:Frigear-nu/frigear-nu/.starters/multi-platform my-app
cd my-app
git init
corepack enable
pnpm install
pnpm prepare:env
pnpm prepare:env creates the .env of each app from its .env.example. It generates NUXT_APP_SECRET for
apps/web and apps/desktop, and the OAuth signing key NUXT_OAUTH_SERVER_PRIVATE_KEY for apps/web. It never
overwrites a value. The other values already point at apps/web on http://localhost:3000:
| Variable | App | What it is |
|---|---|---|
NUXT_ACL_ADMINS | web | Comma separated emails that are always admins, once verified. Put yours here. |
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER, _API_BASE | mobile, desktop (remote) | The issuer and the API: http://localhost:3000. |
DESKTOP_MODE | desktop | remote (the example's value) or local. |
NUXT_FRIGEAR_SSO_URL | desktop (local) | The issuer of the browser handoff: http://localhost:3000. |
NUXT_FRIGEAR_SSO_CLIENT_ID | desktop (local) | Optional. Overrides localClientId of identity.ts (desktop-local). No secret. |
2. Run the apps
pnpm dev
It starts apps/web on http://localhost:3000, apps/mobile on http://localhost:3001 and apps/desktop on
http://localhost:3002. pnpm dev:mobile and pnpm dev:desktop start apps/web with one of the apps, and
pnpm dev:web starts it alone.
3. Sign in on each app
- Open
http://localhost:3000, choose Create account and register with the email fromNUXT_ACL_ADMINS. Open the verification link printed in the terminal and press Continue. - Open
http://localhost:3001, the mobile app. Sign in goes toapps/web, asks for consent and comes back signed in. To run it on a simulator, an iPhone or Android, follow the standalone mobile starter: the commands are the same. - Open
http://localhost:3002, the desktop app. Sign in goes toapps/webthe same way, as the clientdesktop.
apps/web and the result of GET /api/me, called with
their access token.The desktop app in a window
pnpm desktop:setup # installs Rust and Bun if missing, creates apps/desktop/src-tauri/
pnpm dev:web # in one terminal
pnpm desktop:dev # in another: the desktop app in a Tauri window
Under desktop:dev the window loads the dev server, so the sign-in is a redirect inside the window. A built app
(pnpm desktop:build) opens the system browser instead and gets the redirect back as a deep link. The
desktop starter explains src-tauri/, the installers and
the icons.
The desktop app in local mode
Set DESKTOP_MODE=local in apps/desktop/.env, recreate the Tauri project for that mode, and start apps/web with
the desktop app:
pnpm desktop:init --force # overwrites the files init creates, src/lib.rs included
pnpm dev:desktop # or pnpm dev:web, then pnpm desktop:dev for the window
The desktop app now runs its own server with its own SQLite database. Its sign-in page has one button, Sign in with your Example account:
- The app's server starts a handoff attempt and answers
apps/web's authorize URL for the clientdesktop-local. - That URL opens outside the window: in the system browser from a Tauri window, in a new tab from a browser.
- You sign in at
apps/webthere (passkeys work), allow the app, and the browser comes back to the app's server onhttp://127.0.0.1:<port>/auth/frigear(http://localhost:3002/auth/frigearundernuxt dev). The page says Signed in. - The window, which polled the attempt meanwhile, collects its cookie session.
The first sign-in creates the local user from apps/web's verified email. After that the app works offline until the
session ends. There are no local passwords or registration (authentication.settings.password: false).
GET /api/me answers from the app's own server
with your account.What is in the starter
| Path | What it does |
|---|---|
package.json | Root scripts: dev, dev:*, build, build:local, lint, typecheck, typecheck:local, test, prepare:env, db:*, mobile:* and desktop:*. |
AGENTS.md, apps/*/AGENTS.md | Conventions for you and your coding agents. |
apps/web/ | The standalone mobile starter's web app, plus the desktop clients in nuxt.config.ts. |
apps/mobile/ | The mobile starter's app, unchanged. |
apps/desktop/ | The desktop starter's app, signing in at apps/web in both modes. |
apps/desktop/identity.ts | App id, name, both client ids, redirect URIs, dev port 3002 and scopes. Exported as @workspace/desktop/identity. |
apps/web/server/db/migrations/, apps/desktop/server/db/migrations/ | The SQLite migrations of apps/web and of the desktop app's local mode. |
How the apps fit together
apps/web depends on @workspace/mobile and @workspace/desktop to read their identity.ts, and registers one
configured client for the mobile app and two for the desktop app:
import * as desktop from '@workspace/desktop/identity'
import { appName, clientId, devRedirectUri, nativeRedirectUri } from '@workspace/mobile/identity'
export default defineNuxtConfig({
oauthServer: {
cors: {
origins: ['capacitor://localhost', 'https://localhost', ...desktop.webviewOrigins],
paths: ['/api/'],
},
clients: [{
id: clientId, // 'mobile'
name: appName,
redirectUris: [nativeRedirectUri],
devRedirectUris: [devRedirectUri],
}, {
id: desktop.clientId, // 'desktop', remote mode
name: `${desktop.appName} (desktop)`,
redirectUris: [desktop.nativeRedirectUri], // 'com.example.desk:/auth/callback'
devRedirectUris: [desktop.devRedirectUri], // 'http://localhost:3002/auth/callback'
}, {
id: desktop.localClientId, // 'desktop-local', local mode
name: `${desktop.appName} (desktop, local mode)`,
redirectUris: [desktop.loopbackRedirectUri], // 'http://127.0.0.1/auth/frigear', on any port
devRedirectUris: [desktop.localDevRedirectUri], // 'http://localhost:3002/auth/frigear'
corsOrigins: false,
}],
},
})
| Piece | What it does |
|---|---|
desktop | Remote mode's public client: the deep link of the built app, and its dev server under nuxt dev only. |
desktop-local | Local mode's public client. OAuth Server accepts a loopback redirect URI registered without a port on any port (RFC 8252), since the app's server picks a free one at every start. |
corsOrigins: false | The local window only calls its own server, which exchanges the code itself, so the client needs no CORS. |
cors.origins | The webviews of the mobile app and of the remote desktop app, tauri://localhost (macOS, Linux) and http://tauri.localhost (Windows), may call the token endpoints and /api/** with a bearer token. |
The desktop app's nuxt.config.ts switches on DESKTOP_MODE. In local mode it turns on the frigear provider, which
Desktop hands off to the system browser, and points it at apps/web:
export default defineNuxtConfig({
authentication: {
settings: {
afterLogin: '/',
password: false,
oauth: { frigear: { label: `Sign in with your ${appName} account`, icon: 'i-lucide-log-in' } },
pages: { login: true },
},
},
runtimeConfig: {
frigear: {
sso: {
url: process.env.NUXT_FRIGEAR_SSO_URL || 'http://localhost:3000',
clientId: process.env.NUXT_FRIGEAR_SSO_CLIENT_ID || localClientId,
},
},
session: { name: 'desktop-session' },
},
})
frigear.sso. The issuer and the public client id, without a secret, so the app ships none. Both are baked into
the build from .env.
session.name. Under nuxt dev both apps/web and the desktop app set a session cookie on localhost, and
cookies do not tell ports apart. A name of its own keeps the two sessions apart.
The handoff table. The handoff adds auth_frigear_handoffs to the desktop app's database. It is in the committed
migrations, and the built app applies them when it starts.
Rename the apps
The mobile app's names are in apps/mobile/identity.ts, the desktop app's in apps/desktop/identity.ts (appId,
appName, clientId, localClientId, devPort, scopes). apps/web follows both. After changing an appId,
recreate ios/ and android/ (pnpm mobile:native) or run pnpm desktop:sync.
Change the database
After adding a module with tables, or changing a module's options, generate the migrations and commit them:
pnpm db:generate
It runs nuxt db generate for apps/web and for the desktop app in local mode.
Production checklist
Do everything in the standalone mobile starter's checklist
for apps/web and apps/mobile. Then, for the desktop app:
- Set your own
appId,appName,clientIdandlocalClientIdinapps/desktop/identity.ts, and runpnpm desktop:sync. - Remote mode: set
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUERand_API_BASEtoapps/web'shttpsorigin in the environment ofpnpm desktop:build. They are baked in. - Local mode: set
NUXT_FRIGEAR_SSO_URLto the same origin in the environment ofpnpm desktop:build. It is baked in too. - Replace the placeholder icons, set the version, and sign the installers. See Desktop and Local mode.
Next steps
- Local mode – the bundled server, its data folder, secrets and the browser handoff.
- OAuth providers – the handoff flow and its security notes.
- Create it in nuxt.config – configured clients and replacing them per environment.
Desktop starter
Start a macOS, Windows and Linux app on Tauri that signs in at any OpenID Connect issuer, or runs offline with its own users and database, from the desktop starter.
Frigear website app
The reference host app behind frigear.nu, with its modules, content, environment, database and deployment.