Add license keys to a Tauri app
To add license keys to a Tauri v2 app, run cargo add tauri-plugin-licers, register the plugin with your public key, and put app.licers().require()? at the top of the commands you sell. Checks run in Rust and every answer is Ed25519-signed, so neither the web view nor a fake server can unlock the app.
Updated by the Licers team
Set it up
- Create a free account and add a product.
- Copy your public key and product id from the Integration page. The public key is safe to ship inside your app.
- Issue a key: set how many devices it may use, when it expires, and any entitlements.
- Add the code below. On the first check the device is bound to the key; past the device limit a new machine is refused.
cd src-tauricargo add tauri-plugin-licersuse tauri_plugin_licers::LicersExt; #[tauri::command]fn export_pdf(app: tauri::AppHandle) -> Result<String, tauri_plugin_licers::Error> { app.licers().require_feature("pro")?; // or .require() for any valid license Ok("the work you sell".into())} pub fn run() { tauri::Builder::default() .plugin( tauri_plugin_licers::Builder::new("YOUR_PUBLIC_KEY") // safe to ship .product_id("YOUR_PRODUCT_ID") .build(), ) .invoke_handler(tauri::generate_handler![export_pdf]) .run(tauri::generate_context!()) .expect("error while running the app");}{ "identifier": "default", "windows": ["main"], "permissions": ["core:default", "licers:default"]}Ask for the key in your interface
import { invoke } from '@tauri-apps/api/core';import { listen } from '@tauri-apps/api/event'; type License = { state: 'none' | 'licensed' | 'refused' | 'offline'; message: string | null; expiresAt: string | null; features: Record<string, unknown>; lastOk: number | null; keyHint: string | null;}; export const license = () => invoke<License>('plugin:licers|status'); // no networkexport const enterKey = (key: string) => invoke<License>('plugin:licers|activate', { key });export const checkAgain = () => invoke<License>('plugin:licers|check');export const forgetKey = () => invoke<License>('plugin:licers|deactivate'); // Also fires when a key is revoked while the app is running.export const onLicense = (show: (l: License) => void) => listen<License>('licers://changed', e => show(e.payload));The plugin keeps a good key in the app’s data folder and checks it again at the next start and every six hours. A refused key never replaces the stored one.
Protect paid features in Rust
JavaScript runs on your customer’s computer in a window with developer tools. Hiding a button there is fine for the interface, but it protects nothing. Put require() or require_feature("pro") inside the Rust command that does the work. Entitlements are read from the signed part of the answer, so an edited reply cannot add one.
The four states
| State | What it means | What your app should do |
|---|---|---|
none | No key was entered | Show the key field |
licensed | A signed answer said yes | Run |
refused | Expired, revoked, over the device limit, or the answer was not genuine | Show message |
offline | The server could not be reached, and this run has had no signed yes yet | Try again, or allow a few days since lastOk |
lastOk is stored unsigned on the customer’s disk. It is good for a friendly grace period, not for security. For computers that are never online, use a signed offline license file.
Seats, credits, variables and updates
app.licers().client() is the full Rust client: floating seats, usage credits, remote variables and update checks. It blocks, so call it inside spawn_blocking.
Questions and answers
Does it work with Tauri v1?
No, the plugin is for Tauri v2. In v1, call the Rust crate from a command.
Which platforms are supported?
Windows, macOS and Linux. Tests run on Windows; the code has no platform-specific parts of its own.
Do I need an npm package?
No. Call the plugin with invoke from @tauri-apps/api.
Where is the key stored?
In licers.json in the app’s data folder. The interface only ever receives its last characters.
How is the computer identified?
The device id is a SHA-256 hash of the operating system’s machine id (Windows MachineGuid, Linux /etc/machine-id, macOS IOPlatformUUID). It survives reinstalls of your app, and the Node, .NET, Kotlin, Java, Rust, Go, C and C++ SDKs compute the same value on the same machine.
What does it cost?
Nothing today. Every feature is free and unlimited: products, keys, devices, validations, offline files and floating seats. See pricing.