CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-expo-updates

Fetches and manages remotely-hosted assets and updates to your app's JS bundle.

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

Expo Updates

Expo Updates provides comprehensive remote update management for React Native applications, enabling over-the-air updates without requiring app store submissions. It implements the Expo Update protocol for fetching, verifying, and applying remote code updates with built-in security, rollback capabilities, and React integration.

Package Information

  • Package Name: expo-updates
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install expo-updates

Core Imports

import * as Updates from "expo-updates";

For specific imports:

import { 
  checkForUpdateAsync, 
  fetchUpdateAsync, 
  reloadAsync, 
  useUpdates,
  isEnabled,
  updateId 
} from "expo-updates";

CommonJS:

const Updates = require("expo-updates");
const { checkForUpdateAsync, fetchUpdateAsync, reloadAsync } = require("expo-updates");

Basic Usage

import * as Updates from "expo-updates";

// Check if updates are enabled
if (Updates.isEnabled) {
  // Check for available update
  const checkResult = await Updates.checkForUpdateAsync();
  
  if (checkResult.isAvailable) {
    // Download the update
    const fetchResult = await Updates.fetchUpdateAsync();
    
    if (fetchResult.isNew) {
      // Restart with new update
      await Updates.reloadAsync();
    }
  }
}

With React hooks:

import { useUpdates } from "expo-updates";

function UpdatesScreen() {
  const {
    currentlyRunning,
    isUpdateAvailable,
    isUpdatePending,
    isDownloading
  } = useUpdates();

  useEffect(() => {
    if (isUpdatePending) {
      // Update downloaded, restart app
      Updates.reloadAsync();
    }
  }, [isUpdatePending]);

  return (
    <View>
      <Text>
        {currentlyRunning.isEmbeddedLaunch 
          ? "Running embedded code" 
          : "Running downloaded update"}
      </Text>
      {isUpdateAvailable && (
        <Button 
          title="Download Update" 
          onPress={() => Updates.fetchUpdateAsync()} 
        />
      )}
      {isDownloading && <Text>Downloading...</Text>}
    </View>
  );
}

Architecture

Expo Updates is built around several key components:

  • Update Protocol: Implements secure manifest-based update discovery and verification
  • Native Bridge: iOS and Android implementations handle update storage and application
  • State Machine: Tracks update lifecycle with events for checking, downloading, and applying updates
  • React Integration: Hooks and components for declarative update management
  • Security Layer: Code signing verification and rollback protection
  • CLI Tools: Command-line utilities for update deployment and debugging

Capabilities

Update Management

Core update lifecycle functions for checking, downloading, and applying remote updates with full error handling and state tracking.

function checkForUpdateAsync(): Promise<UpdateCheckResult>;
function fetchUpdateAsync(): Promise<UpdateFetchResult>;
function reloadAsync(options?: { reloadScreenOptions?: ReloadScreenOptions }): Promise<void>;

Update Management

App State and Configuration

Runtime information about the current update state, configuration, and app lifecycle including update IDs, channels, and launch conditions.

const isEnabled: boolean;
const updateId: string | null;
const channel: string | null;
const runtimeVersion: string | null;
const isEmbeddedLaunch: boolean;
const isEmergencyLaunch: boolean;
const emergencyLaunchReason: string | null;
const launchDuration: number | null;
const checkAutomatically: UpdatesCheckAutomaticallyValue | null;
const manifest: Partial<Manifest>;
const createdAt: Date | null;

App State and Configuration

React Integration

React hooks and utilities for declarative update management with real-time state tracking and automatic UI updates.

function useUpdates(): UseUpdatesReturnType;

interface UseUpdatesReturnType {
  currentlyRunning: CurrentlyRunningInfo;
  isStartupProcedureRunning: boolean;
  isUpdateAvailable: boolean;
  isUpdatePending: boolean;
  isChecking: boolean;
  isDownloading: boolean;
  isRestarting: boolean;
  restartCount: number;
  availableUpdate?: UpdateInfo;
  downloadedUpdate?: UpdateInfo;
  downloadProgress?: number;
  checkError?: Error;
  downloadError?: Error;
  lastCheckForUpdateTimeSinceRestart?: Date;
}

React Integration

Advanced Configuration

Advanced features for customizing update behavior including extra parameters, request overrides, and developer utilities.

function getExtraParamsAsync(): Promise<Record<string, string>>;
function setExtraParamAsync(key: string, value: string | null | undefined): Promise<void>;
function setUpdateURLAndRequestHeadersOverride(configOverride: { updateUrl: string; requestHeaders: Record<string, string> } | null): void;
function setUpdateRequestHeadersOverride(requestHeaders: Record<string, string> | null): void;

Advanced Configuration

Logging and Debugging

Comprehensive logging system for debugging update issues with structured log entries, filtering, and management capabilities.

function readLogEntriesAsync(maxAge?: number): Promise<UpdatesLogEntry[]>;
function clearLogEntriesAsync(): Promise<void>;

interface UpdatesLogEntry {
  timestamp: number;
  message: string;
  code: UpdatesLogEntryCode;
  level: UpdatesLogEntryLevel;
  updateId?: string;
  assetId?: string;
  stacktrace?: string[];
}

Logging and Debugging

Developer Utilities

Testing and debugging utilities available in debug builds for development and testing purposes.

function showReloadScreen(options?: { reloadScreenOptions?: ReloadScreenOptions }): Promise<void>;
function hideReloadScreen(): Promise<void>;

Types

Core Types

type Manifest = ExpoUpdatesManifest | EmbeddedManifest;

interface CurrentlyRunningInfo {
  updateId?: string;
  channel?: string;
  createdAt?: Date;
  isEmbeddedLaunch: boolean;
  isEmergencyLaunch: boolean;
  emergencyLaunchReason: string | null;
  launchDuration?: number;
  manifest?: Partial<Manifest>;
  runtimeVersion?: string;
}

enum UpdatesCheckAutomaticallyValue {
  ON_LOAD = 'ON_LOAD',
  ON_ERROR_RECOVERY = 'ON_ERROR_RECOVERY',
  WIFI_ONLY = 'WIFI_ONLY',
  NEVER = 'NEVER'
}

enum UpdateInfoType {
  NEW = 'new',
  ROLLBACK = 'rollback'
}

interface UpdateInfoNew {
  type: UpdateInfoType.NEW;
  updateId: string;
  createdAt: Date;
  manifest: Manifest;
}

interface UpdateInfoRollback {
  type: UpdateInfoType.ROLLBACK;
  updateId: undefined;
  createdAt: Date;
  manifest: undefined;
}

type UpdateInfo = UpdateInfoNew | UpdateInfoRollback;

Update Results

type UpdateCheckResult = UpdateCheckResultRollBack | UpdateCheckResultAvailable | UpdateCheckResultNotAvailable;

interface UpdateCheckResultAvailable {
  isAvailable: true;
  manifest: Manifest;
  isRollBackToEmbedded: false;
  reason: undefined;
}

interface UpdateCheckResultNotAvailable {
  isAvailable: false;
  manifest: undefined;
  isRollBackToEmbedded: false;
  reason: UpdateCheckResultNotAvailableReason;
}

type UpdateFetchResult = UpdateFetchResultSuccess | UpdateFetchResultFailure | UpdateFetchResultRollBackToEmbedded;

interface UpdateFetchResultSuccess {
  isNew: true;
  manifest: Manifest;
  isRollBackToEmbedded: false;
}

Reload Screen Configuration

interface ReloadScreenOptions {
  backgroundColor?: string;
  image?: string | number | ReloadScreenImageSource;
  imageResizeMode?: 'contain' | 'cover' | 'center' | 'stretch';
  imageFullScreen?: boolean;
  fade?: boolean;
  spinner?: {
    enabled?: boolean;
    color?: string;
    size?: 'small' | 'medium' | 'large';
  };
}

interface ReloadScreenImageSource {
  url?: string;
  width?: number;
  height?: number;
  scale?: number;
}

CLI Tools

The package includes a command-line interface for development and deployment tasks:

npx expo-updates --help

# Available commands:
npx expo-updates codesigning:generate    # Generate code signing certificates
npx expo-updates codesigning:configure   # Configure code signing
npx expo-updates assets:verify           # Verify asset integrity
npx expo-updates fingerprint:generate    # Generate runtime fingerprint
npx expo-updates runtimeversion:resolve  # Resolve runtime version
npx expo-updates configuration:syncnative # Sync configuration to native
Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/expo-updates@29.0.x
Publish Source
CLI
Badge
tessl/npm-expo-updates badge