@appspacer/capacitor
v1.0.1
Published
AppSpacer OTA live updates for Capacitor apps
Maintainers
Readme
@appspacer/capacitor
Over-The-Air (OTA) live updates for Capacitor apps. Ship JavaScript, HTML, and CSS changes to your web build instantly — no app store review required.
The plugin checks AppSpacer for a newer web bundle, verifies its SHA-256, unzips it, and serves your app from the updated bundle on the next launch. Push releases with the AppSpacer CLI.
Full documentation: docs.appspacer.com
Installation
npm install @appspacer/capacitor
npx cap syncRequirements: Capacitor 6.
Quick Start
Initialize the SDK early in your app's startup (e.g. in your root component or main.ts), then sync:
import { AppSpacer } from '@appspacer/capacitor';
await AppSpacer.init({
deploymentKey: 'your-deployment-key',
appVersion: '1.0.0',
});
// Check for, download, and apply an update in one call.
const result = await AppSpacer.sync();
if (result.updateAvailable) {
console.log('Update applied:', result.label);
}After a bundle is downloaded and applied, call AppSpacer.reload() (or relaunch) to load it.
Publishing an update
Build your web app, then push the output with the CLI:
# Android — auto-detects www/dist/build
appspacer release-capacitor -p android -a my-app -d Production -t 1.0.0
# iOS — explicit build directory, mandatory update
appspacer release-capacitor -p ios -a my-app -d Production -t 1.0.0 --mandatory -f ./distZip the contents of the web build (with index.html at the top level). The plugin verifies the SHA-256, unzips the bundle, and serves it from the new path.
API
AppSpacer.init(config)
Initialize the plugin. Must be called before any other method.
interface AppSpacerConfig {
deploymentKey: string; // Deployment key from your AppSpacer dashboard
appVersion: string; // The native app store version this build targets
serverUrl?: string; // Override the API base URL (self-hosted). Default: https://api.appspacer.com/api
debugLogging?: boolean; // Verbose logging. Default: false
}AppSpacer.sync(): Promise<UpdateCheckResult>
Check for an update and, if one is available, download and apply it. Returns the check result.
AppSpacer.checkForUpdate(): Promise<UpdateCheckResult>
Check whether an update is available without downloading it.
interface UpdateCheckResult {
updateAvailable: boolean;
releaseId?: string;
packageUrl?: string;
hash?: string;
mandatory?: boolean;
description?: string;
label?: string;
packageSize?: number;
}AppSpacer.reload(): Promise<void>
Reload the WebView to load the most recently applied bundle.
AppSpacer.resetToBuiltIn(): Promise<void>
Discard any downloaded bundle and revert to the bundle shipped inside the binary.
AppSpacer.getDeviceId(): Promise<{ deviceId: string }>
Return the stable per-install device identifier used for staged rollouts.
Links
- Dashboard: appspacer.com
- CLI: @appspacer/cli
- Documentation: docs.appspacer.com
- Support: appspacer.com/support
License
MIT
