All posts

How to setup license keys in a Tauri application

Nicholas Affonso

November 04, 2025

How to setup license keys in a Tauri application

Tauri makes it easy to build lightweight, universal desktop apps with web technologies, but protecting your paid app from unauthorized use requires a proper licensing system.

With Keyforge, you can secure your Tauri apps with licenses, including offline verifications, using simple REST API calls. This guide has both JavaScript and Rust examples to help you get started.

Activate a license in your Tauri app

When a user opens your app for the first time, prompt them to enter their license key. Then, call the Keyforge activation endpoint to link that license to the user's device.

const res = await fetch(
  'https://keyforge.dev/api/v1/public/licenses/activate',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      licenseKey: 'ABCDE-ABCDE-ABCDE-ABCDE-ABCDE',
      deviceIdentifier: 'unique_device_id',
      deviceName: 'My computer',
      productId: 'p_123456',
    }),
  }
);

console.log('License activated:', await res.json());

Getting a device identifier

Use any stable unique identifier, such as a hardware ID, or a persistently stored UUID.

After activation, store the license key securely (for example, using tauri-plugin-stronghold or MacOS Keychain). This allows your app to re-validate it later without asking the user again.

Validate the license on startup

Each time your app launches, verify the stored license to ensure it's still active and valid. You can do this on startup or at scheduled intervals.

const res = await fetch(
  'https://keyforge.dev/api/v1/public/licenses/validate',
  {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      licenseKey: savedLicenseKey,
      deviceIdentifier: 'unique_device_id',
      productId: 'p_123456',
    }),
  }
);

const data = await res.json();
if (data.isValid) {
  console.log('License is valid');
} else {
  console.log('License invalid');
}

If Keyforge returns "isValid": true, your app can safely unlock the licensed features.


Offline licensing

If users need to use your app without an active internet connection, Keyforge supports offline license validations using signed JWT tokens. Each license can be represented as a signed token that your app securely verifies locally.

Payments and customer management

You can automate the entire licensing workflow by connecting Stripe to Keyforge. When someone purchases or subscribes to your app, a license is automatically generated and sent to them by email.

Additionally, you can also provide a self-service customer portal where users can view and manage their licenses without any manual work.

Conclusion

With Keyforge, you can easily add secure license protection to your Tauri app in just a few lines of code, helping you monetize and distribute your software.

Use the REST API to activate and validate licenses, give users offline access when needed, and connect Stripe to automate licenses, all without maintaining your own backend.

Simplify your licensing process

Focus on building your product and let us handle licensing. Generate license keys via Stripe and offer your customers a smooth self-serve experience.