DEV Community

Mo Qunaybi
Mo Qunaybi

Posted on

How I Built a Cross-Platform App Using Tauri and Python FastAPI

Talking first about the front-end framework Tauri, Tauri was first introduced in 2019 as an alternative to electron to leverage native web view of operating system instead of using chromium web view on all platform. This approach eats less memory. The fundamental approach of Tauri is to write your backend code in Rust which works very good cross-platform desktop application. However, when needing to run apps on the web which its possible to extract the front end and use REST api architecture to communicate between frontend and backend by using vite and the command pnpm run. This could save so much time by creating desktop, mobile, web application all in one front-end source code. In this article, I will explain how I built iHives a e-commerce platform. Using web tools such as Vite, Tauri, and FastApi.

The process is simple by following the documentation on Tauri v2 webpage. In TauriV2 you can select any package manager you are familiar with to install Tauri in my case I picked pnpm, I used to use npm, but after the breach this year I switched to pnpm. Anyway, afterwords you will be prompted to name the project, select front end language. Like so in the figure below.

I am using reactJS for this project and installed Shadcn UI library to enhance ui/ux of the website. By using Shadcn plus Tailwind you can easier manipulate the screen responsive dimensions, so you can adjust it to each screen whether it's a mobile, web, or desktop screen.

For the api endpoints, using python Fastapi with Redis to enhance response time to nearly microseconds. This architecture saved me a lot of time in configuration as one person working on the project. You can still use Rust code for the desktop, and mobile built, but when it comes for the web page you ought to use an api served on the server to execute business logic.

Top comments (0)