Zeeshan Ali Khan 5fdc616df9 feat: Use the zbus-backed of notify-rust (#6332) 2 gadi atpakaļ
..
core 5fdc616df9 feat: Use the zbus-backed of notify-rust (#6332) 2 gadi atpakaļ
src 46e6187c89 chore: update license year (#6311) 2 gadi atpakaļ
static 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
.gitignore 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
.npmrc 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
README.md 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
package.json 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
svelte.config.js 46e6187c89 chore: update license year (#6311) 2 gadi atpakaļ
tsconfig.json 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ
vite.config.ts 46e6187c89 chore: update license year (#6311) 2 gadi atpakaļ
yarn.lock 6c13840cee feat(examples): add desktop/web application example (#5537) 2 gadi atpakaļ

README.md

Desktop / Web Example

This example showcases an application that has shares code between a desktop and a Web target.

The Web application uses WASM to communicate with the Rust backend, while the desktop app leverages Tauri commands.

Architecture

The Rust code lives in the core/ folder and it is a Cargo workspace with three crates:

  • tauri: desktop application. Contains the commands that are used by the frontend to access the Rust APIs;
  • wasm: library that is compiled to WASM to be used by the Web application;
  • api: code shared between the Tauri and the WASM crates. Most of the logic should live here, with only the specifics in the tauri and wasm crates.

The Rust code bridge is defined in the src/api/ folder, which defines desktop/index.js and a web/index.js interfaces. To access the proper interface according to the build target, a resolve alias is defined in vite.config.js, so the API can be imported with import * as api from '$api'.

Running the desktop application

Use the following commands to run the desktop application:

yarn
yarn tauri dev

Running the Web application

Use the following commands to run the Web application:

yarn
yarn dev:web