Electron
Electron apps combine desktop runtime needs with web-style UI patterns. FFDB works well here when you treat the app as local-first and explicitly model sync state in the interface.
Why Electron setup is different
- Name
Desktop process lifecycle- Description
Electron apps may run longer than browser tabs, so cleanup and reconnect behavior matter more.
- Name
Offline by default expectations- Description
Desktop users often expect full usability during poor connectivity.
- Name
Template choices- Description
FFDB CLI supports Electron starts with Vite + React or Vite + Vanilla TypeScript.
CLI setup flow
ffdb-cli init
Recommended prompt path:
- Platform: Electron
- Template: Vite + React or Vite + Vanilla TypeScript
- Optional offline support: better-sqlite3
- Optional Tailwind CSS
- Env setup: writes
VITE_FFDB_API_URLandFFDB_AUTH_TOKEN
Core client setup
import { createClient } from 'ffdb-client'
import type { Database } from './ffdb.types'
const client = await createClient<Database>({
config: {
apiUrl: import.meta.env.VITE_FFDB_API_URL,
},
})
const { db, auth, sync, destroy } = client
Desktop offline pattern
When you enable offline mode, wire a local adapter and show sync status in the UI:
const { sync } = await createClient<Database>({
config: {
apiUrl: import.meta.env.VITE_FFDB_API_URL,
},
storage: desktopStorageAdapter,
offline: {
adapter: localSqliteAdapter,
syncOnReconnect: true,
syncOnFocus: true,
syncInterval: 30_000,
},
})
if (sync) {
const off = sync.subscribe(() => {
console.log(sync.status)
})
await sync.run()
off()
}
Practical guidance
- Treat offline support as a product decision, not just a technical option.
- Expose online/offline and pending mutation state in visible UI.
- Use explicit teardown (
destroy) during app shutdown flows. - Keep privileged credentials in trusted runtime boundaries only.
Do not embed admin-level credentials directly in renderer bundles. Use user auth flows and trusted setup environments for privileged operations.