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
Name | Type |
---|---|
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.