BrowserWindow and adds desktop-specific behavior such as deep-link authentication, system tray support, native window chrome, and auto-updates.
Scaffold with the CLI
When you runnpx @chat-js/cli@latest create, the CLI asks:
electron/ subfolder into your project:
chat.config.ts.
Development
Start the web app first, then launch Electron:http://localhost:3000 by default.
Authentication
OAuth redirects cannot return directly to an in-apphttp://localhost page inside Electron. ChatJS uses @better-auth/electron to bridge the browser sign-in flow back into the desktop app with a custom URL scheme and PKCE.
How it works
The main integration points are:- Server:
lib/auth.tsenables the Electron Better Auth plugin - Web client:
lib/auth-client.tshandles the browser-side redirect flow - Electron main:
src/main.tssets up deep-link handling and IPC bridges - Electron preload:
src/preload.tsexposes auth bridges to the renderer
Custom URL Scheme
The desktop auth scheme comes fromappPrefix in chat.config.ts.
Auto-Updates
The desktop integration useselectron-updater with GitHub Releases. When a packaged app starts, it can check for updates and apply them on a later quit.
The GitHub repository used for updates is configured in electron-builder.config.js:
Customization
App icon
Replaceelectron/icon.png with your own 512x512 PNG, then regenerate the platform-specific assets:
App name, scheme, and production URL
Editchat.config.ts in your project root:
branding.json file from those values so the desktop app stays aligned with your web app branding.
Building for Distribution
Build desktop installers from theelectron/ directory:
electron/release/.
- macOS:
.dmg - Windows:
.exeinstaller - Linux:
.AppImageand.deb
Release Flow
In the ChatJS monorepo, desktop releases follow the same version-bump PR model used for package releases:- Add a changeset that includes
@chatjs/electron - Let the Changesets workflow open the version PR
- Merge that version PR
- The Electron release workflow reads the new
apps/electron/package.jsonversion, builds macOS, Windows, and Linux artifacts, and publishes them to GitHub Releases
macOS Distribution Notes
For public macOS distribution outside the App Store, you will usually want:- code signing
- notarization
- a stable bundle identifier and install path