Skip to content

Repository files navigation

Tauri v2 + Next.js Monorepo
Tauri v2 + Next.js Monorepo

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.

Features

  • 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.

Getting Started

Prerequisites

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)

Installation

  1. Clone the repository:

    git clone https://github.com/Arbarwings/tauri-v2-nextjs-monorepo.git
    cd tauri-v2-nextjs-monorepo
  2. Install dependencies:

    pnpm install

Running the Apps

Web (Next.js):

pnpm --filter web dev

Desktop (Tauri):

pnpm --filter native dev

Mobile (iOS/Android via Tauri):

Refer to the Tauri Mobile Guide for additional setup.

Shared Components

The packages/ui directory contains shared UI components, hooks, and utilities built with:

These components ensure consistency across web, desktop, and mobile platforms.

API Endpoints

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
          }
        }
      }

Folder Structure

.
├── 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

Commands

  • 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.

Contributing

Contributions are welcome! Please fork the repository and create a pull request with your changes.

License

This project is licensed under the MIT License.


References

About

Tauri v2 with Next.js monorepo setup with shared components and reusable backend APIs. The project supports deployment across Web, iOS, Android, Windows, macOS, and Linux.

Resources

Stars

90 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages