tauri-csv-explorer is a cross-platform desktop application for viewing and exploring CSV files. It's a demonstration of building a modern desktop app using Tauri, with a robust separation of concerns between a Rust backend and a SvelteKit frontend.
The application has been tested on macOS and Linux (Ubuntu).
This application follows a clear separation of concerns pattern.
src-csv
). We use Polars to read CSV files. While it may be oversized for this simple use case, it showcases the potential of Rust for Data Science applications.invoke
API.The application is built to fulfill the following requirements:
.csv
files by default.Search for REQ-xxx in the codebase to locate the corresponding code snippets.
src-csv
)The core logic for processing CSV files, including metadata extraction (e.g., delimiter detection), resides in its own Rust crate. This demonstrates how to build a UI for an existing library. A CLI version of this library can be used independently to confirm functionality.
For visualizing the CSV data, the Svelte Datagrid is used. The chosen component is ideal for handling and displaying tabular data efficiently.
To change the application icon, use the Tauri CLI:
pnpm tauri icon path/to/your/icon.png
After changing the icon in the src-tauri
directory, a cargo clean
is required to ensure the changes are reflected in the build.
The application leverages Tauri's built-in error propagation. Errors from the Rust backend are automatically sent to the frontend, allowing for unified error handling.
pnpm tauri add dialog
set permissions in ./src-tauri/capabilities/default.json: "dialog:allow-open"
pnpm install wx-svelte-grid
If no defaultPath
is set, the Path is set first on $HOME/Documents
and after one selection to the latest used directory.
When the Tauri app is started from the CLI, the first positional parameter is the CSV filename. Since we already use existing Clap logic in src-csv
, the Tauri CLI plugin is not needed !
The menu is implemented in TypeScript, as it belongs to the frontend.
To set the application title, the following permission must be added:
pnpm tauri permission add "core:window:allow-set-title"
Otherwise, the title will not update, and only an error will appear in the browser console:
Unhandled Promise Rejection: window.set_title not allowed. Permissions associated with this command: core:window:allow-set-title
For visualization the Svelte Datagrid is used.
Alternative: https://github.com/joaquimnetocel/svelte-datatables-net
Error Handling https://v2.tauri.app/develop/calling-rust/#error-handling Errors from the Rust backend are propagated to the Frontend.
Demo to use a new icon
pnpm tauri icon taurirc/assets/icon_csv_text.png
After changing the icon in src-tauri
a cargo clean
is needed to reflect the changes.
.csv
)Files with Extension .csv
should opened with the application.
Implementation:
In ./src-tauri/tauri.conf.json add fileAssociations
:
"bundle": {
"fileAssociations": [
{
"ext": [
"csv"
],
"name": "CSV File",
"role": "Editor",
"mimeType": "text/csv",
"description": "A comma-separated values file."
}
],
Releases are automated using GitHub Actions. The workflow for publishing the app is defined in .github/workflows/publish-tauri-app.yml
When a new release is available it should be installed automatically. This currently only works for demonstration purposes with an AppImage on Ubuntu ARM.
To support this on macOS Apple the app must be signed (an Apple Developer account is needed). For Windows a signed release must be created.
Add the plugin
cargo tauri add updater
Tauri updater signs the apps. So create Tauri Keys
pnpm tauri signer generate -w ~/.tauri/myapp.key
This Keys have to be added to your ./src-tauri/tauri.conf.json:
createUpdaterArtifacts true
"bundle": {
...
"createUpdaterArtifacts": true
},
"plugins": {
...
"updater": {
"pubkey": "TODO: insert",
"endpoints": [
"https://github.com/TODO:user/TODO:repo/releases/latest/download/latest.json"
]
}
more: https://v2.tauri.app/plugin/updater/#tauri-configuration
In Github TAURI_SIGNING_PRIVATE_KEY
and TAURI_SIGNING_PRIVATE_KEY_PASSWORD
have to be configured as secrets to sign a update release, e.g.:
echo $TAURI_SIGNING_PRIVATE_KEY | gh secret set TAURI_SIGNING_PRIVATE_KEY
echo $TAURI_SIGNING_PRIVATE_KEY_PASSWORD | gh secret set TAURI_SIGNING_PRIVATE_KEY_PASSWORD
VS Code + Svelte + Tauri + rust-analyzer.