A Tauri v2 app with Rust-based license activation via Keymint.
npm install
npm run tauri devThe frontend is plain HTML in src/, served by Tauri straight from frontendDist. There is no separate dev server to start.
Set your Keymint credentials as environment variables before building:
export KEYMINT_CLIENT_API_KEY=km_live_your_client_api_key_here
export KEYMINT_PRODUCT_ID=prod_your_product_id_here
npm run tauri dev| Variable | Description |
|---|---|
KEYMINT_CLIENT_API_KEY |
Client API key from the Keymint dashboard |
KEYMINT_PRODUCT_ID |
Your product ID |
These are read at compile time via option_env!(). Set them before cargo build / npm run tauri dev.
The client key ships inside your app. Anything compiled into the binary can be extracted by anyone who has a copy of it. Use a key with the
clientscope, bound to this product, and never anadminkey. Treat the client key as public and rotate it from the dashboard if it is abused.
- Rust license module — activate, deactivate, status check via Keymint REST API
- Machine binding — host ID derived from the OS machine ID (
machine-uidcrate), hashed before it is sent (see Host ID) - Local persistence — stores license state in
license.jsonunder the OS local data directory (see License state file) - Activation UI — plain HTML/JS frontend that calls Rust via Tauri
invoke()from thewindow.__TAURI__global (app.withGlobalTauri), so no remote scripts are loaded and it works offline - Key masking — stored keys are masked when returned to the frontend
├── src/
│ └── index.html # Frontend activation dialog
├── src-tauri/
│ ├── Cargo.toml # Rust dependencies
│ ├── tauri.conf.json # Tauri config
│ └── src/
│ ├── main.rs # Tauri builder + command registration
│ └── license.rs # License activation/deactivation logic
└── package.json
| Command | Description |
|---|---|
activate_license |
Activate a license key against the Keymint API |
deactivate_license |
Deactivate the current license |
is_activated |
Check if a valid license is stored |
get_license_status |
Get masked key + activation state |
The activation state is saved as license.json in a tauri-license-starter folder inside the OS local data directory (dirs::data_local_dir()):
| OS | Path |
|---|---|
| Linux | ~/.local/share/tauri-license-starter/license.json (or $XDG_DATA_HOME/tauri-license-starter/) |
| macOS | ~/Library/Application Support/tauri-license-starter/license.json |
| Windows | %LOCALAPPDATA%\tauri-license-starter\license.json |
Change the folder name in license_file_path() in src-tauri/src/license.rs to match your app.
Each activation is tied to a host ID. The starter computes it in src-tauri/src/license.rs as the lowercase hex SHA-256 of a fixed, app-specific prefix (HOST_ID_PREFIX) followed by the OS machine ID. The result is always 64 characters, the maximum the API accepts, and the raw machine ID never leaves the device.
- Change
HOST_ID_PREFIXto something unique to your app before your first release, then keep it. Changing it later changes every install's host ID. - If the machine ID can't be read,
activate_licenseanddeactivate_licensereturn the error "Couldn't read a device ID for this computer…", which the activation screen displays. There is no shared fallback ID, so machines without a readable ID never share one activation slot. - If you need to keep sending the raw machine ID (for continuity with installs that activated before hashing),
host_id_from_machine_idhas a one-line commented alternative. Hashed is the default and is recommended.
Earlier versions of this starter sent the raw OS machine ID as the host ID, and fell back to the shared value unknown-host when it couldn't be read. Host IDs are now hashed, so an install that activated with an earlier build reports a different host ID after upgrading:
- The first time it activates with the new build, it uses one more activation slot. Its old activation stays on the license until you remove it, for example with
POST /key/deactivateand an admin API key. - Deactivating from the upgraded install sends the new host ID, so it can't release the old activation. Remove that one yourself in the same way.
If your licenses are close to their activation limit, raise the limit or clear old activations before shipping the upgrade. To avoid the change entirely, use the raw-ID line described above.