@crabnebula/ota-updater

中文文档
0.1.9发布于 2025/07/28PolyForm-Noncommercial-1.0.0TypeScriptCommonJS零依赖近 30 天下载 2711

This plugin provides over-the-air (OTA) updates for the Web assets of a Tauri app.

原始使用文档
文档目录5 节
  1. Install
  2. Configuration
  3. Distributing Updates
  4. Usage
  5. License

Over-the-air (OTA) Updater

This plugin provides over-the-air (OTA) updates for the Web assets of a Tauri app.

It leverages the CrabNebula Cloud to ship the assets.

Install

This plugin requires a Rust version of at least 1.75

There are three general methods of installation that we can recommend.

  1. Use crates.io and npm (easiest, and requires you to trust that our publishing pipeline worked)
  2. Pull sources directly from Github using git tags / revision hashes (most secure)
  3. Git submodule install this repo in your tauri project and then use file protocol to ingest the source (most secure, but inconvenient to use)

Install the Core plugin by adding the following to your Cargo.toml file:

src-tauri/Cargo.toml

[dependencies]
tauri-plugin-ota-updater = "2.0.0-rc"

You can install the JavaScript Guest bindings using your preferred JavaScript package manager:

pnpm add @crabnebula/plugin-ota-updater
# or
npm add @crabnebula/plugin-ota-updater
# or
yarn add @crabnebula/plugin-ota-updater

Configuration

You need a signing key to sign the update bundle. This ensures the integrity of your code can be checked at runtime. To generate a new signing key run the generate-keypair command:

npx @crabnebula/ota-updater generate-keypair

Safely store the private key and DO NOT share it with anyone. It will be required to distribute updates later.

The plugin must be configured with the signing public key and CrabNebula Cloud org/app slug pair:

{
    "plugins": {
        "ota-updater": {
            "orgSlug": "my-org",
            "appSlug": "my-app",
            "pubkey": "<insert-public-key-here>"
        }
    }
}

To be able to use the updater from the frontend of your application you need to enable the default permission of the plugin in your capability ( e.g. capabilities/default.json):

{
...
  "permissions": [
    "ota-updater:default"
  ]
...
}

Distributing Updates

To distribute updates, build your frontend assets and then run the upload command providing the private key and a CrabNebula Cloud API key as environment variables:

export PRIVATE_KEY=<insert-private-key-here>
export CN_API_KEY=<insert api-key-here>
npx @crabnebula/ota-updater upload

Usage

First you need to register the core plugin with Tauri:

src-tauri/src/main.rs

fn main() {
    let context = tauri::generate_context!();

    let (ota_plugin, context) = tauri_plugin_ota_updater::init(context);

    tauri::Builder::default()
        .plugin(ota_plugin)
        .run(context)
        .expect("error while running tauri application");
}

Afterwards all the plugin's APIs are available through the JavaScript guest bindings:

import { check } from "@crabnebula/plugin-ota-updater";
const update = await check()
if (update) {
    await update.apply()
    location.reload()
}

License

Code: (c) 2023 - Present - CrabNebula Ltd.

PolyForm-Noncommercial-1.0.0

版本与发布记录

@crabnebula/ota-updater 共发布 9 个版本,首次发布于 2024/09/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.9latest2025/07/281.3 年前
0.1.82025/07/231.3 年前
0.1.72025/07/041.4 年前
0.1.62025/01/221.8 年前
0.1.52025/01/211.8 年前
0.1.42024/09/082 年前

关于 @crabnebula/ota-updater 的常见问题

@crabnebula/ota-updater 是什么?

This plugin provides over-the-air (OTA) updates for the Web assets of a Tauri app.

如何安装 @crabnebula/ota-updater?

在项目目录运行 npm install @crabnebula/ota-updater,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ota-updater,可以用 npx ota-updater 直接运行。

@crabnebula/ota-updater 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crabnebula/ota-updater 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@crabnebula/ota-updater 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 10。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@crabnebula/ota-updater 可以商用吗?

@crabnebula/ota-updater 使用 PolyForm-Noncommercial-1.0.0 许可。声明的许可为 PolyForm-Noncommercial-1.0.0,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@crabnebula/ota-updater 的下载量有多少?

根据 npm 官方下载统计,@crabnebula/ota-updater 在 2026/10/11 – 2026/11/09 这 30 天内被下载 2,711 次,日均约 90 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crabnebula/ota-updater 还在维护吗?

最新版本 0.1.9 发布于 2025/07/28(1.3 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/09/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。