An open API service indexing awesome lists of open source software.

https://github.com/dieharders/example-tauri-python-server-sidecar

An example desktop app built using the Tauri framework to bundle Next.js with a Python server.
https://github.com/dieharders/example-tauri-python-server-sidecar

desktop-app fastapi native-apps nextjs pnpm python scaffold-template tauri-app

Last synced: 5 months ago
JSON representation

An example desktop app built using the Tauri framework to bundle Next.js with a Python server.

Awesome Lists containing this project

README

          

# Example Tauri v1 app using Python sidecar

A native app built with Tauri v1 that spawns a Python sub-process (sidecar) which starts a FastAPI server.

![Python](https://img.shields.io/badge/-Python-000?&logo=Python)
![TypeScript](https://img.shields.io/badge/-TypeScript-000?&logo=TypeScript)
![Rust](https://img.shields.io/badge/-Rust-000?&logo=Rust)


![FastAPI](https://img.shields.io/badge/-FastAPI-000?&logo=fastapi)
![NextJS](https://img.shields.io/badge/-NextJS-000?&logo=nextdotjs)
![Tauri](https://img.shields.io/badge/-Tauri-000?&logo=Tauri)

> [!IMPORTANT]
>
> Tauri v2 example is now available 👇
>
> example-tauri-v2-python-server-sidecar

>
> More features and documentation with example app.exe.

![logo](extras/sidecar-logo.png "python sidecar logo")

## Introduction

This example app uses Next.js as the frontend and Python (FastAPI) as the backend. Tauri is a Rust framework that orchestrates the frontend and backend(s) into a native app experience.

## How It Works

![python sidecar architecture](extras/diagram.png "python sidecar architecture")

Tauri takes your frontend UI written in html/javascript and displays it in a native webview. This makes the resulting file size smaller since it does not need to include a web browser.

## Getting Started

### Dependencies

Install dependencies for javascript:

```bash
pnpm install
```

To install python dependencies listed in requirements.txt:

```bash
pnpm dev-reqs
```

In case you dont have PyInstaller installed:

```bash
pip install -U pyinstaller
```

### Run

To run the app in development mode with hot-reload (js):

```bash
pnpm tauri dev
```

### Build

#### Compile python sidecar

Run this at least once before running `pnpm tauri dev` and each time you make changes to your python code. This command is also called by `pnpm tauri build`:

```bash
pnpm build:fastapi
```

#### Build app for production:

```bash
pnpm tauri build
```

This creates an installer located here:

- \\src-tauri\target\release\bundle\nsis

## Learn More

- [Tauri Framework](https://tauri.app/) - learn about native app development in javascript and rust.
- [NextJS](https://nextjs.org/docs) - learn about the popular react framework Next.js
- [FastAPI](https://fastapi.tiangolo.com/) - learn about FastAPI server features and API.
- [PyInstaller](https://pyinstaller.org/en/stable/) - learn about packaging python code.