updater

Tell people a new version is ready and update the app in place, on the web, desktop and mobile.

PlatformsClient

What it is

@kitr/updater tells people a new version is ready and applies it in place. One check() and apply() flow, one status, a useUpdate hook and a ready-made banner.

Runs in the browser only. The web driver watches the service worker; desktop and mobile plug in their own.

Install

kitr add updater

First time? Run npm i -g @kitr/kitr once. Inside a project, the global kitr runs your project's own version.

Adds @kitr/updater, its provider, config/updater.ts and a banner in app/components/update-banner.tsx. Every change.

Quick start

kitr add writes this banner:

// app/components/update-banner.tsx
import { useUpdate } from '@kitr/updater/react'

/** Mount once in the root layout. Hidden until the updater has something ready. */
export function UpdateBanner() {
  const { available, update, status, progress, apply, dismiss } = useUpdate()
  if (!available) return null
  return (
    <div role="status">
      <span>Version {update?.version} is ready.</span>
      <button type="button" onClick={apply} disabled={status === 'downloading'}>
        {status === 'downloading' ? `Updating ${Math.round(progress * 100)}%` : 'Restart to update'}
      </button>
      <button type="button" onClick={dismiss}>
        Later
      </button>
    </div>
  )
}

Mount it once in app/document.tsx. Deploy a new build and the bar appears: "Version new is ready. Restart to update · Later". One click reloads on the new build. Next in the guide: Show your first update banner.

Built on

Where Driver built on
Web The service worker that the web platform's pwa option builds with vite-plugin-pwa. Applying activates the waiting worker and reloads.
Desktop electron-updater or Tauri's updater, through a driver the shell registers.
Mobile A store or over-the-air driver the shell registers.

kitr adds the status machine, periodic checks, "remind me later", the hook, the banner and the UpdaterDriver interface.

Problems it solves

Further reading