A production-ready template for building cross-platform desktop applications using Tauri with Modern.js and React.
- Ant Design desktop shell: Responsive header, sidebar navigation, and content area styled with custom LESS tokens.
- Stateful Modern.js route: Zustand drives the sidebar state and persists the latest Rust greeting for a real desktop workflow.
- Realtime context: A Day.js-powered clock and Lucide React icons provide live status cues.
- Rust ↔ React example: Trigger the bundled
greetTauri command directly from the UI to verify the round trip. - Cross-platform ready: Build for Windows, macOS (Intel & Apple Silicon), and Linux with the provided Modern.js + Tauri toolchain.
- Framework: Modern.js v2.67.7
- UI Library: React 19 + Ant Design 5
- Bundler: Rspack (configurable to Webpack)
- Styling: LESS
- State Management: Zustand
- Icons: Lucide React
- Date Handling: Day.js
- Runtime: Tauri v2
- Language: Rust
- Build Tool: Cargo
Before you begin, ensure you have the following installed:
- Node.js (v18 or later)
- Bun (latest version)
- Rust (latest stable)
- System Dependencies:
- Linux:
sudo apt-get install libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf - macOS: Xcode Command Line Tools
- Windows: Microsoft C++ Build Tools
- Linux:
git clone https://github.com/gedankrayze/tauri-modernjs
cd tauri-modernjs# Install frontend dependencies with Bun (recommended)
bun install
# or with npm
npm install
# Install Rust dependencies (handled automatically by Tauri)# Start development server with Bun
bun run tauri:dev
# or using npm
npm run tauri:devThis will:
- Start the Modern.js dev server on
http://localhost:8080 - Launch the Tauri application in development mode
- Enable hot reloading for both frontend and backend changes
# Build the application with Bun
bun run tauri:build
# or using npm
npm run tauri:buildLaunch the desktop app and click Run greet in the header to call the greet Tauri command. The response is stored in the
shared Zustand store and rendered in the "Latest activity" card.
Prefer to call it manually? The UI uses the same helper you can reuse elsewhere:
import {invoke} from '@tauri-apps/api/core';
const message = await invoke<string>('greet', {name: 'Modern.js Developer'});Run scripts with either Bun (bun run <script>) or npm (npm run <script>):
dev- Start the Modern.js development server only.build- Build the frontend for production.tauri:dev- Start the integrated Tauri development mode.tauri:build- Bundle the desktop application for production.
tauri-modernjs/
├── .github/
│ └── workflows/
│ └── build.yml # GitHub Actions CI/CD
├── public/
│ └── tauri.svg # Static assets
├── src/
│ ├── routes/
│ │ └── layout.tsx # Main layout component
│ ├── stores/
│ │ └── appStore.ts # Shared Zustand state
│ ├── global.d.ts # Global TypeScript declarations
│ ├── global.less # Global styles
│ └── modern-app-env.d.ts # Modern.js environment types
├── src-tauri/
│ ├── src/
│ │ ├── lib.rs # Main Tauri library
│ │ └── main.rs # Application entry point
│ ├── icons/ # Application icons
│ ├── Cargo.toml # Rust dependencies
│ └── tauri.conf.json # Tauri configuration
├── modern.config.ts # Modern.js configuration
├── package.json # Node.js dependencies
└── tsconfig.json # TypeScript configuration
The modern.config.ts file contains:
- Bundler: Rspack (faster) or Webpack
- Router: Enabled for SPA routing
- Global Variables: APP_NAME available in components
- Performance: Optimized chunk splitting
- LESS: Configured with JavaScript support
The src-tauri/tauri.conf.json file contains:
- Window Settings: 800x600 default size
- Build Commands: Integration with Modern.js
- Security: CSP disabled for development
- Bundle Settings: Multi-platform support
- Chunk splitting with
split-by-experiencestrategy - Vendor chunk separation
- LESS compilation optimizations
- Link Time Optimization (LTO)
- Single codegen unit for smaller binaries
- Panic abort for release builds
- Binary stripping for reduced size
The included workflow (.github/workflows/build.yml) provides:
- Push to
mainbranch - Pull requests to
main - Release creation
- Linux: Ubuntu latest (x86_64)
- Windows: Windows latest (x86_64)
- macOS Intel: macOS latest (x86_64)
- macOS Apple Silicon: macOS latest (aarch64)
- Windows:
.msiand.exeinstallers - Linux:
.debpackages and.AppImagebinaries - macOS:
.dmgdisk images and.appbundles
- Create a release on GitHub
- Workflow automatically builds for all platforms
- Compressed artifacts are attached to the release
Edit the following files:
package.json: Update name, description, versionsrc-tauri/Cargo.toml: Update package namesrc-tauri/tauri.conf.json: Update productName, identifier, window titlemodern.config.ts: Update APP_NAME global variable
- Define commands in
src-tauri/src/lib.rs:
#[tauri::command]
fn my_command(param: String) -> String {
format!("Hello, {}!", param)
}- Register in the handler:
.invoke_handler(tauri::generate_handler![greet, my_command])- Use in frontend:
import { invoke } from '@tauri-apps/api/core';
const result = await invoke('my_command', { param: 'World' });Frontend:
bun add <package-name>
bun add -d <dev-package-name>Backend:
cd src-tauri
cargo add <crate-name>- Build fails on Linux: Ensure WebKit dependencies are installed
- Rust compilation errors: Update Rust to latest stable version
- Frontend not loading: Check if dev server is running on port 8080
- Use
bun run tauri:devfor development with hot reloading - Check Tauri logs in the terminal for backend debugging
- Use browser DevTools for frontend debugging
- Monitor bundle size with the performance configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Test on multiple platforms
- Submit a pull request
This template is provided as-is for educational and commercial use.