This repository contains the source code of the blog post Tauri v2 with Next.js: A Monorepo Guide. It demonstrates how to build a cross-platform application using Tauri v2 for desktop and mobile apps, and Next.js for web services.
- Next.js for web and API services.
- Tauri v2 for building lightweight and performant native desktop and mobile apps.
- Monorepo setup powered by TurboRepo.
- Shared components built with TailwindCSS, Shadcn, and Lucide for a consistent UI across platforms.
- Reusable backend API using Next.js API routes.
- Cross-platform deployment for Web, iOS, Android, Windows, macOS, and Linux.
Ensure the following tools are installed:
- Node.js (v22+)
- pnpm (v8+)
- Rust (Install Rust)
- Xcode (for iOS development) (Optional)
- Android Studio (for Android development) (Optional)
-
Clone the repository:
git clone https://github.com/Arbarwings/tauri-v2-nextjs-monorepo.git cd tauri-v2-nextjs-monorepo -
Install dependencies:
pnpm install
pnpm --filter web devpnpm --filter native devRefer to the Tauri Mobile Guide for additional setup.
The packages/ui directory contains shared UI components, hooks, and utilities
built with:
These components ensure consistency across web, desktop, and mobile platforms.
The backend API for text analysis is powered by Next.js API routes. The main endpoint is:
-
POST /api/text-analysis-
Request body:
{ "text": "Your text here" } -
Response:
{ "success": true, "data": { "id": "unique-id", "timestamp": "2025-01-27T12:00:00Z", "analysis": { "wordCount": 100, "charCount": 500, "mostFrequentWord": "example", "sentimentScore": 1.5 } } }
-
.
├── apps
│ ├── web # Next.js app for web and API
│ ├── native # Tauri app for desktop and mobile
├── packages
│ ├── ui # Shared components, styles, and utilities
│ ├── typescript-config # Shared TypeScript configurations
│ ├── eslint-config # Shared ESLint configurations
└── turbo.json # TurboRepo configuration
pnpm dev: Start the development server for all apps.pnpm tauri: Exposes the Tauri CLI for running the desktop or mobile app.pnpm tauri dev: Start the Tauri desktop app in development mode.pnpm tauri android dev: Start the Tauri android app in development mode.pnpm tauri ios dev: Start the Tauri iOS app in development mode.pnpm lint: Lint the codebase using ESLint.pnpm format: Format the codebase using Prettier.pnpm clean: Remove all build artifacts.pnpm check-types: Check TypeScript types.pnpm shadcn: Exposes the Shadcn CLI for generating components.
Contributions are welcome! Please fork the repository and create a pull request with your changes.
This project is licensed under the MIT License.