A boilerplate Electron desktop application built with React, TanStack Router, and TanStack Query.
Features an embedded PostgreSQL database (Pglite), authentication system, and a full-stack architecture with IPC communication between Electron main and renderer processes.
- Framework: Electron + React 19 + Vite
- Routing: TanStack Router with file-based route generation
- Data Fetching: TanStack Query (React Query)
- Database: Drizzle ORM with Pglite (embedded PostgreSQL)
- Styling: Tailwind CSS + Radix UI
- Validation: Zod
- Build: Electron Forge
- Desktop application with native window management
- File-based routing with automatic route tree generation
- Embedded PostgreSQL database (no external server required)
- Authentication system with session management
- Dashboard with users, invoices, and posts management
- Auto-update support
- IPC communication between main and renderer processes
- Type-safe database schema and validation
electron-tanstack-router/
├── src/
│ ├── main/ # Electron main process
│ │ ├── db/ # Database schema and connection
│ │ ├── features/ # Business logic (auth, etc.)
│ │ ├── window/ # Window management
│ │ ├── config/ # App configuration
│ │ ├── menu.ts # Application menu
│ │ ├── main.ts # Entry point
│ │ └── update/ # Auto-update logic
│ ├── preload/ # Preload scripts for IPC
│ │ ├── modules/ # Exposed APIs
│ │ └── services/ # Bridge services
│ └── renderer/ # React UI (renderer process)
│ ├── routes/ # File-based routes
│ ├── components/ # React components
│ ├── lib/ # Utilities and configurations
│ └── providers/ # Context providers
├── forge.config.ts # Electron Forge configuration
├── drizzle.config.ts # Drizzle configuration
├── tsr.config.json # TanStack Router CLI config
└── package.json
- Node.js 18+
- npm
npm installRun the development server with hot module replacement:
npm run devThis will:
- Watch routes for changes (via
tsr watch) - Start Vite dev server
- Enable hot module replacement
Build the application for production:
npm run buildPackage the application for distribution:
npm run packageOr create installers:
npm run make| Command | Description |
|---|---|
npm run dev |
Start development server with route watching |
npm run build |
Build production bundles |
npm run generate-routes |
Generate TanStack Router route tree |
npm run watch-routes |
Watch routes directory for changes |
npm run generate-schema |
Generate Drizzle migrations |
npm run sync-schema |
Push schema changes to database |
npm run start |
Start Electron app with route watcher |
npm run package |
Package app for distribution |
npm run make |
Create installers |
npm run lint |
Run ESLint |
The application uses Pglite, an embedded PostgreSQL implementation that runs in the main process. Database schema is managed via Drizzle ORM.
To push schema changes:
npm run sync-schemaTo generate migrations:
npm run generate-schemaBackend API routes are registered in src/main/features/ :
/api/auth/*- Authentication endpoints (login, register, logout, session)
API routes are served via a custom IPC handler in the preload layer.