Desktop starter
What you'll have afterwards:
- A desktop app for macOS, Windows and Linux, also runnable in a browser on
http://localhost:3001. - In remote mode, the app signs you in at an issuer you already have. In local mode, it has its own users and database and works offline.
- A Home page that shows the desktop shell, who signed in and the result of
/api/me, and an Account page that signs you out.
Use this starter for a desktop app. It is a pnpm workspace with one app in apps/desktop,
on Desktop (Tauri v2). The app runs in one of two modes, picked by DESKTOP_MODE in
apps/desktop/.env:
| Mode | What ships in the app | Sign-in |
|---|---|---|
remote (default) | A static Nuxt 4 single-page app (SPA) that calls a remote API | At a remote issuer, with Auth in client mode: 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) | Email and password on the app's own server, with Auth in server mode |
Both modes take their guards from Authorization, and share the same pages.
Prerequisites
The tools in Requirements, plus:
| Tool | For | Installed by pnpm desktop:setup |
|---|---|---|
| Rust | Every OS: cargo and rustc from rustup.rs. | macOS, Linux |
| Your OS's prerequisites | The Xcode Command Line Tools on macOS, the C++ Build Tools and WebView2 on Windows, WebKitGTK 4.1 on Linux. See Desktop prerequisites. | The Xcode tools (Apple's dialog) |
| Bun | Local mode only, to compile the server: bun.sh. The app's users do not need it. | Every OS |
pnpm dev runs the app in a browser without any of them.
1. Create the project
Copy .starters/desktop 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 desktop
cd my-app
git init
pnpx giget@latest gh:Frigear-nu/frigear-nu/.starters/desktop my-app
cd my-app
git init
corepack enable
pnpm install
pnpm prepare:env
pnpm prepare:env copies apps/desktop/.env.example to apps/desktop/.env and generates NUXT_APP_SECRET. It never
overwrites a value.
| Variable | Mode | What it is |
|---|---|---|
DESKTOP_MODE | Both | remote (the example's value) or local. |
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER | Remote | The issuer URL, for example https://frigear.nu. The example file sets http://localhost:3000. |
NUXT_PUBLIC_AUTHENTICATION_CLIENT_API_BASE | Remote | The API that useApi() and $api call with the access token. Without it: the issuer. |
NUXT_PUBLIC_AUTHENTICATION_CLIENT_CLIENT_ID | Remote | Optional. Overrides clientId of identity.ts. |
NUXT_PUBLIC_AUTHENTICATION_CLIENT_SCOPE | Remote | Optional. Overrides scopes of identity.ts, space separated. Must include openid. |
NUXT_APP_SECRET | Local | Seals the session cookie under pnpm dev. The built app generates its own secrets on first start. |
2. Create the Tauri project
Set DESKTOP_MODE first (step 5 switches later), then:
pnpm desktop:setup
pnpm desktop:setup runs frigear-desktop doctor --fix. It installs what is missing: Rust with the rustup installer,
in local mode Bun with bun.sh's installer, and the Tauri packages. Then it runs frigear-desktop init, which creates
apps/desktop/src-tauri/ for the current mode, with the Rust project, the Tauri plugins, placeholder icons and the
settings from nuxt.config.ts, and checks again. You do not need a new terminal afterwards. It never runs sudo: on
Linux and Windows it prints what to install by hand (Set up a machine).
pnpm desktop:doctor only checks.
The starter has no src-tauri/, because what init writes depends on the mode: local mode adds the shell plugin and
the code that starts the bundled server. Commit src-tauri/ once it exists. Its .gitignore keeps target/,
gen/schemas and binaries/ out.
src-tauri/src/lib.rs is yours after init. tauri.conf.json and capabilities/frigear.json are partly the module's:
pnpm desktop:sync, and every desktop:dev and desktop:build, merges the desktop options into them. See
What the module writes.3. Choose the issuer (remote mode)
Set NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUER (and _API_BASE) in apps/desktop/.env, then register a publicOAuth application at the issuer, one that uses PKCE and has no secret. Use the values from
apps/desktop/identity.ts:
| What | Value in the starter |
|---|---|
| Client id | desktop (clientId) |
| Redirect URI of the built app | com.example.desk:/auth/callback (appId in lowercase, then callbackPath) |
| Redirect URI for development | http://localhost:3001/auth/callback (pnpm dev and pnpm desktop:dev) |
| Cross-origin resource sharing (CORS) origins | tauri://localhost (macOS, Linux), http://tauri.localhost (Windows), http://localhost:3001 (development) |
| Scopes | openid profile email. Add offline_access for issuers that need it for a refresh token (Keycloak, Auth0, ...). |
On an issuer running OAuth Server, that is one configured client:
export default defineNuxtConfig({
oauthServer: {
cors: { paths: ['/api/'] },
clients: [{
id: 'desktop',
name: 'Example for desktop',
redirectUris: ['com.example.desk:/auth/callback'],
devRedirectUris: ['http://localhost:3001/auth/callback'],
corsOrigins: ['tauri://localhost', 'http://tauri.localhost'],
}],
},
})
The standalone mobile starter's apps/web is such an issuer on
http://localhost:3000, with /api/me: add the client above next to the mobile one. For other issuers,
Use your own OAuth server has the checklist.
4. Run it
pnpm dev # http://localhost:3001 in a browser
pnpm desktop:dev # the same app in a Tauri window
Every page needs a signed-in user (the '/**' route rule), so you land on /login:
- Remote mode. Sign in goes to the issuer. Under
desktop:devthe window loads the dev server, so the sign-in is a redirect inside the window, back tohttp://localhost:3001/auth/callback. A built app opens the system browser instead, and gets the redirect back as a deep link. - Local mode. Create an account on the sign-in page and sign in. There is no email verification: nobody would receive the email offline.
GET /api/me. Account signs you out.5. Switch to local mode
Set DESKTOP_MODE=local in apps/desktop/.env, then recreate the Tauri project for that mode:
pnpm desktop:init --force # overwrites the files init creates, src/lib.rs included
pnpm desktop:dev
nuxt.config.ts now adds NuxtHub, Users and Auth in server mode, and extends the local/ layer, which holds the
server routes (local/server/api/me.get.ts). Under pnpm dev and pnpm desktop:dev the database is NuxtHub's, in
apps/desktop/.data/, with the migrations applied on start.
pnpm desktop:init --force replaces src-tauri/src/lib.rs. Copy your own changes to it first.6. Build the installers
pnpm desktop:build
The installers end up in apps/desktop/src-tauri/target/release/bundle/ (a .dmg and .app on macOS, .msi and
.exe on Windows, .deb, .rpm and .AppImage on Linux). Each OS builds its own. Options after -- go to the
Tauri CLI, for example pnpm desktop:build -- --bundles dmg.
- Remote mode runs
nuxt generateand bundles the SPA.NUXT_PUBLIC_*values are baked in, so set the production issuer in the environment of the build. - Local mode runs
nuxt build, compiles the server with Bun intosrc-tauri/binaries/, then bundles it. On first start the app creates its database and secrets in the user's app-data folder and appliesserver/db/migrations.pnpm desktop:sidecarbuilds only the server, to try it without Tauri.
Rename the app
Everything that names the app is in apps/desktop/identity.ts:
export const appId = 'com.example.desk' // Tauri identifier and, in lowercase, the deep-link scheme
export const appName = 'Example' // window title, installer and bundle name
export const clientId = 'desktop' // the OAuth client_id (remote mode)
export const callbackPath = '/auth/callback'
export const devPort = 3001 // pnpm dev and the window of pnpm desktop:dev
export const scopes = ['openid', 'profile', 'email'] // add 'offline_access' for issuers that need it
After changing appId, run pnpm desktop:sync and register the new redirect URI at the issuer. Use lowercase letters,
digits, . and -, and avoid a last segment of app. Replace the placeholder icons with
npx tauri icon path/to/logo.png, see Icons.
Change the database (local mode)
After adding a module with tables, or changing a module's options, generate a migration and commit it:
pnpm db:generate
It runs nuxt db generate in local mode and writes to apps/desktop/server/db/migrations/sqlite/. The built app
applies the pending migrations when it starts.
What is in the starter
| Path | What it does |
|---|---|
package.json | Root scripts: dev, build, build:local, lint, typecheck, typecheck:local, test, prepare:env, db:generate and desktop:*. |
pnpm-workspace.yaml | Lists apps/* and packages/*. |
AGENTS.md | Conventions for you and your coding agents. |
packages/eslint-config/ | Shared lint config for packages you add. |
apps/desktop/identity.ts | App id, name, client id, callback path, dev port and scopes. Exported as @workspace/desktop/identity. |
apps/desktop/nuxt.config.ts | The modules, the '/**' route rule, and authentication, hub and desktop for the mode in DESKTOP_MODE. |
apps/desktop/.env.example | DESKTOP_MODE, the issuer and API of remote mode, NUXT_APP_SECRET of local mode. |
apps/desktop/app/app.vue | <UApp> with a top bar once signed in. |
apps/desktop/app/app.config.ts | Sign-in page branding of remote mode (authentication.login). |
apps/desktop/app/pages/index.vue | Home: useDesktop(), useUserSession().user and useApi('/api/me'). |
apps/desktop/app/pages/account.vue | Account: profile and sign-out. |
apps/desktop/local/ | A layer extended in local mode only, with the server routes. |
apps/desktop/server/db/migrations/ | The SQLite migrations of local mode. |
Next steps
- Desktop – the options,
useDesktop(), deep links and what the module writes intosrc-tauri/. - Local mode – how the bundled server starts, its data folder, secrets and limitations.
- Desktop CLI – every
frigear-desktopcommand and the prerequisites per OS. - Auth in client mode – the sign-in flows and token storage in a Tauri window.
Standalone mobile starter
Start a mobile app with its own backend - a Nuxt 4 web app that is the OAuth server and API, and a Capacitor app that signs in at it - from the standalone mobile starter.
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.