TypeScript/JavaScript API bindings for Tauri applications providing comprehensive desktop app functionality
—
The app module provides APIs for managing application lifecycle, retrieving metadata, and controlling application-level behavior across platforms.
Retrieve information about the current application.
/**
* Get the application version
* @returns Promise resolving to version string
*/
function getVersion(): Promise<string>;
/**
* Get the application name
* @returns Promise resolving to app name
*/
function getName(): Promise<string>;
/**
* Get the Tauri version being used
* @returns Promise resolving to Tauri version string
*/
function getTauriVersion(): Promise<string>;
/**
* Get the application identifier
* @returns Promise resolving to app identifier
*/
function getIdentifier(): Promise<string>;
/**
* Get the bundle type of the current application
* @returns Promise resolving to bundle type
*/
function getBundleType(): Promise<BundleType>;
enum BundleType {
/** Windows NSIS */
Nsis = 'nsis',
/** Windows MSI */
Msi = 'msi',
/** Linux Debian package */
Deb = 'deb',
/** Linux RPM package */
Rpm = 'rpm',
/** Linux AppImage */
AppImage = 'appimage',
/** macOS app bundle */
App = 'app'
}Usage Examples:
import { getVersion, getName, getTauriVersion, getBundleType } from '@tauri-apps/api/app';
// Get basic app information
const appName = await getName();
const appVersion = await getVersion();
const tauriVersion = await getTauriVersion();
console.log(`${appName} v${appVersion} (Tauri ${tauriVersion})`);
// Check bundle type for platform-specific behavior
const bundleType = await getBundleType();
if (bundleType === BundleType.App) {
console.log('Running on macOS');
} else if (bundleType === BundleType.Nsis || bundleType === BundleType.Msi) {
console.log('Running on Windows');
}Control application visibility and focus, particularly on macOS.
/**
* Show the application (macOS only)
* Does not automatically focus any specific window
* @returns Promise that resolves when operation completes
*/
function show(): Promise<void>;
/**
* Hide the application (macOS only)
* @returns Promise that resolves when operation completes
*/
function hide(): Promise<void>;Usage Examples:
import { show, hide } from '@tauri-apps/api/app';
// Show application in dock (macOS)
await show();
// Hide application from dock (macOS)
await hide();Control the application's theme appearance.
/**
* Set the application theme
* @param theme - Theme to apply ('light', 'dark', or null for system default)
* @returns Promise that resolves when theme is applied
*/
function setTheme(theme?: Theme | null): Promise<void>;
type Theme = 'light' | 'dark';Usage Examples:
import { setTheme } from '@tauri-apps/api/app';
// Set dark theme
await setTheme('dark');
// Set light theme
await setTheme('light');
// Use system theme
await setTheme(null);Control dock visibility and behavior on macOS.
/**
* Set dock icon visibility (macOS only)
* @param visible - Whether dock icon should be visible
* @returns Promise that resolves when visibility is set
*/
function setDockVisibility(visible: boolean): Promise<void>;Usage Examples:
import { setDockVisibility } from '@tauri-apps/api/app';
// Hide from dock (useful for background/menu bar apps)
await setDockVisibility(false);
// Show in dock
await setDockVisibility(true);Access the default window icon for the application.
/**
* Get the default window icon
* @returns Promise resolving to Image instance or null if no icon
*/
function defaultWindowIcon(): Promise<Image | null>;Usage Example:
import { defaultWindowIcon } from '@tauri-apps/api/app';
const icon = await defaultWindowIcon();
if (icon) {
const size = await icon.size();
console.log(`Default icon size: ${size.width}x${size.height}`);
}Manage application data stores and their lifecycle.
/**
* Get identifiers for all data stores
* @returns Promise resolving to array of data store identifiers
*/
function fetchDataStoreIdentifiers(): Promise<DataStoreIdentifier[]>;
/**
* Remove a data store
* @param identifier - Data store identifier to remove
* @returns Promise that resolves when store is removed
*/
function removeDataStore(identifier: DataStoreIdentifier): Promise<void>;
type DataStoreIdentifier = [
number, number, number, number,
number, number, number, number,
number, number, number, number,
number, number, number, number
];Usage Examples:
import { fetchDataStoreIdentifiers, removeDataStore } from '@tauri-apps/api/app';
// List all data stores
const stores = await fetchDataStoreIdentifiers();
console.log(`Found ${stores.length} data stores`);
// Remove a specific data store
if (stores.length > 0) {
await removeDataStore(stores[0]);
console.log('Removed first data store');
}show() and hide() control application visibility in docksetDockVisibility() can create menu bar only applicationsshow() and hide() have limited effect, primarily for integration scenariossetDockVisibility() is a no-opimport { getName, show } from '@tauri-apps/api/app';
try {
const name = await getName();
await show();
} catch (error) {
// Common error scenarios:
// - Permission denied
// - Platform not supported
// - Application state conflicts
console.error('App operation failed:', error);
}import { getName, getVersion, setTheme, setDockVisibility } from '@tauri-apps/api/app';
import { getCurrentWindow } from '@tauri-apps/api/window';
// Create a menu bar app
async function setupMenuBarApp() {
await setDockVisibility(false);
const window = getCurrentWindow();
await window.setSkipTaskbar(true);
await window.setAlwaysOnTop(true);
}
// Setup app info display
async function displayAppInfo() {
const name = await getName();
const version = await getVersion();
document.title = `${name} v${version}`;
}
// Theme synchronization
async function syncTheme() {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
await setTheme(prefersDark ? 'dark' : 'light');
}Install with Tessl CLI
npx tessl i tessl/npm-tauri-apps--api