Starters

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.

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:

ModeWhat ships in the appSign-in
remote (default)A static Nuxt 4 single-page app (SPA) that calls a remote APIAt a remote issuer, with Auth in client mode: 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)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:

ToolForInstalled by pnpm desktop:setup
RustEvery OS: cargo and rustc from rustup.rs.macOS, Linux
Your OS's prerequisitesThe 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)
BunLocal 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

pnpm prepare:env copies apps/desktop/.env.example to apps/desktop/.env and generates NUXT_APP_SECRET. It never overwrites a value.

VariableModeWhat it is
DESKTOP_MODEBothremote (the example's value) or local.
NUXT_PUBLIC_AUTHENTICATION_CLIENT_ISSUERRemoteThe issuer URL, for example https://frigear.nu. The example file sets http://localhost:3000.
NUXT_PUBLIC_AUTHENTICATION_CLIENT_API_BASERemoteThe API that useApi() and $api call with the access token. Without it: the issuer.
NUXT_PUBLIC_AUTHENTICATION_CLIENT_CLIENT_IDRemoteOptional. Overrides clientId of identity.ts.
NUXT_PUBLIC_AUTHENTICATION_CLIENT_SCOPERemoteOptional. Overrides scopes of identity.ts, space separated. Must include openid.
NUXT_APP_SECRETLocalSeals 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)

In remote mode the app does not sign in until the issuer knows it. Register it there before the first run. Skip this step for local 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:

WhatValue in the starter
Client iddesktop (clientId)
Redirect URI of the built appcom.example.desk:/auth/callback (appId in lowercase, then callbackPath)
Redirect URI for developmenthttp://localhost:3001/auth/callback (pnpm dev and pnpm desktop:dev)
Cross-origin resource sharing (CORS) originstauri://localhost (macOS, Linux), http://tauri.localhost (Windows), http://localhost:3001 (development)
Scopesopenid 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:

nuxt.config.ts (issuer)
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:dev the window loads the dev server, so the sign-in is a redirect inside the window, back to http://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.
What you should see: a window titled Example. Home says it runs in the desktop app with your OS and version, and shows your sign-in and the result of 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 generate and 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 into src-tauri/binaries/, then bundles it. On first start the app creates its database and secrets in the user's app-data folder and applies server/db/migrations. pnpm desktop:sidecar builds only the server, to try it without Tauri.

Rename the app

Everything that names the app is in apps/desktop/identity.ts:

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

PathWhat it does
package.jsonRoot scripts: dev, build, build:local, lint, typecheck, typecheck:local, test, prepare:env, db:generate and desktop:*.
pnpm-workspace.yamlLists apps/* and packages/*.
AGENTS.mdConventions for you and your coding agents.
packages/eslint-config/Shared lint config for packages you add.
apps/desktop/identity.tsApp id, name, client id, callback path, dev port and scopes. Exported as @workspace/desktop/identity.
apps/desktop/nuxt.config.tsThe modules, the '/**' route rule, and authentication, hub and desktop for the mode in DESKTOP_MODE.
apps/desktop/.env.exampleDESKTOP_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.tsSign-in page branding of remote mode (authentication.login).
apps/desktop/app/pages/index.vueHome: useDesktop(), useUserSession().user and useApi('/api/me').
apps/desktop/app/pages/account.vueAccount: 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 into src-tauri/.
  • Local mode – how the bundled server starts, its data folder, secrets and limitations.
  • Desktop CLI – every frigear-desktop command and the prerequisites per OS.
  • Auth in client mode – the sign-in flows and token storage in a Tauri window.
Copyright © 2026