Starters

Multi-platform starter

Start a web app that is the OAuth server and API, a Capacitor mobile app and a Tauri desktop app that both sign in at it, from the multi-platform starter.

What you'll have afterwards:

  • A web app on http://localhost:3000 with sign-up, sign-in, account pages and an admin area, signed in with the admin role.
  • 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/web has sign-up and sign-in, a /dashboard users land on, /account pages and an admin area with user management. With OAuth Server it is also the issuer and the API of the other two apps.
  • apps/mobile is a Capacitor app on Mobile. It signs in at apps/web with Auth in client mode and calls /api/me with its access token.
  • apps/desktop is a Tauri v2 app on Desktop. It signs in at apps/web in either mode, picked by DESKTOP_MODE in apps/desktop/.env:
ModeWhat ships in the appSign-in at apps/web
remote (default)A static Nuxt 4 SPA that calls apps/web's APIAuth in client mode, client desktop: the system browser, and the redirect back as a deep link
localThe 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
There is nothing to register by hand. 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:

ToolFor
XcodeiOS: a recent Xcode with an iOS simulator.
Android StudioAndroid: a Java Development Kit (JDK) and the Android SDK.
Rust and your OS's prerequisitesThe 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.
BunThe 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

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:

VariableAppWhat it is
NUXT_ACL_ADMINSwebComma separated emails that are always admins, once verified. Put yours here.
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER, _API_BASEmobile, desktop (remote)The issuer and the API: http://localhost:3000.
DESKTOP_MODEdesktopremote (the example's value) or local.
NUXT_FRIGEAR_SSO_URLdesktop (local)The issuer of the browser handoff: http://localhost:3000.
NUXT_FRIGEAR_SSO_CLIENT_IDdesktop (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

  1. Open http://localhost:3000, choose Create account and register with the email from NUXT_ACL_ADMINS. Open the verification link printed in the terminal and press Continue.
  2. Open http://localhost:3001, the mobile app. Sign in goes to apps/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.
  3. Open http://localhost:3002, the desktop app. Sign in goes to apps/web the same way, as the client desktop.
What you should see: both apps show your account from 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:

  1. The app's server starts a handoff attempt and answers apps/web's authorize URL for the client desktop-local.
  2. That URL opens outside the window: in the system browser from a Tauri window, in a new tab from a browser.
  3. You sign in at apps/web there (passkeys work), allow the app, and the browser comes back to the app's server on http://127.0.0.1:<port>/auth/frigear (http://localhost:3002/auth/frigear under nuxt dev). The page says Signed in.
  4. 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).

What you should see:Home says it runs in local mode, and GET /api/me answers from the app's own server with your account.

What is in the starter

PathWhat it does
package.jsonRoot scripts: dev, dev:*, build, build:local, lint, typecheck, typecheck:local, test, prepare:env, db:*, mobile:* and desktop:*.
AGENTS.md, apps/*/AGENTS.mdConventions 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.tsApp 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:

apps/web/nuxt.config.ts
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,
    }],
  },
})
PieceWhat it does
desktopRemote mode's public client: the deep link of the built app, and its dev server under nuxt dev only.
desktop-localLocal 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: falseThe local window only calls its own server, which exchanges the code itself, so the client needs no CORS.
cors.originsThe 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:

apps/desktop/nuxt.config.ts (local mode)
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, clientId and localClientId in apps/desktop/identity.ts, and run pnpm desktop:sync.
  • Remote mode: set NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER and _API_BASE to apps/web's https origin in the environment of pnpm desktop:build. They are baked in.
  • Local mode: set NUXT_FRIGEAR_SSO_URL to the same origin in the environment of pnpm 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

Copyright © 2026