Skip to main content

updater

@tauri-apps/api / updater

Module: updater

Customize the auto updater flow.

This package is also accessible with window.__TAURI__.updater when build.withGlobalTauri in tauri.conf.json is set to true.

Interfaces​

Type Aliases​

UpdateStatus​

UpdateStatus: "PENDING" | "ERROR" | "DONE" | "UPTODATE"

Defined in​

updater.ts:14

Functions​

checkUpdate​

checkUpdate(): Promise<UpdateResult>

Checks if an update is available.

Example

import { checkUpdate } from '@tauri-apps/api/updater';
const update = await checkUpdate();
// now run installUpdate() if needed

Returns​

Promise<UpdateResult>

Promise resolving to the update status.


installUpdate​

installUpdate(): Promise<void>

Install the update if there's one available.

Example

import { checkUpdate, installUpdate } from '@tauri-apps/api/updater';
const update = await checkUpdate();
if (update.shouldUpdate) {
console.log(`Installing update ${update.manifest?.version}, ${update.manifest?.date}, ${update.manifest.body}`);
await installUpdate();
}

Returns​

Promise<void>

A promise indicating the success or failure of the operation.


onUpdaterEvent​

onUpdaterEvent(handler): Promise<UnlistenFn>

Listen to an updater event.

Example

import { onUpdaterEvent } from "@tauri-apps/api/updater";
const unlisten = await onUpdaterEvent(({ error, status }) => {
console.log('Updater event', error, status);
});

// you need to call unlisten if your handler goes out of scope e.g. the component is unmounted
unlisten();

Parameters​

NameType
handler(status: UpdateStatusResult) => void

Returns​

Promise<UnlistenFn>

A promise resolving to a function to unlisten to the event. Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.