Skip to main content

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​

UpdateManifest​

Since: 1.0.0

Properties​

body​

body: string

Defined in: updater.ts:34

date​

date: string

Defined in: updater.ts:33

version​

version: string

Defined in: updater.ts:32

UpdateResult​

Since: 1.0.0

Properties​

manifest​

Optional manifest: UpdateManifest

Defined in: updater.ts:41

shouldUpdate​

shouldUpdate: boolean

Defined in: updater.ts:42

UpdateStatusResult​

Since: 1.0.0

Properties​

error​

Optional error: string

Defined in: updater.ts:24

status​

status: UpdateStatus

Defined in: updater.ts:25

Type Aliases​

UpdateStatus​

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

Since: 1.0.0

Defined in: updater.ts:18

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

Since: 1.0.0

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();
}

Since: 1.0.0

Returns: Promise<void>

A promise indicating the success or failure of the operation.

onUpdaterEvent​

onUpdaterEvent(handler: fn): 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();

Since: 1.0.2

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.