
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@markvivanco/app-version-checker
Advanced tools
React App version checking and update prompts for React, React Native, and web applications
Universal app version checking and update prompts for React, React Native, and web applications.
npm install app-version-checker
# or
yarn add app-version-checker
# or
pnpm add app-version-checker
import { VersionChecker } from 'app-version-checker';
import { LocalStorageProvider } from 'app-version-checker/stores';
// Create your data provider
class MyDataProvider {
getCurrentVersion() {
return '1.0.0';
}
async getLatestVersion(platform) {
// Fetch from your API
const response = await fetch(`/api/version/${platform}`);
const data = await response.json();
return data.version;
}
getAppStoreConfig() {
return {
iosAppStoreId: '123456789',
androidPackageName: 'com.example.app'
};
}
}
// Initialize the checker
const checker = new VersionChecker(
new MyDataProvider(),
new LocalStorageProvider(),
{
minCheckInterval: 60 * 60 * 1000, // 1 hour
remindLaterDuration: 24 * 60 * 60 * 1000, // 24 hours
}
);
// Check for updates
const result = await checker.shouldShowUpdatePrompt();
if (result.shouldShowPrompt) {
// Show your update dialog
console.log(`Update available: ${result.versionInfo.latestVersion}`);
}
import React from 'react';
import { VersionCheckProvider, useVersionCheck } from 'app-version-checker/react';
import { LocalStorageProvider } from 'app-version-checker/stores';
// Your update dialog component
const UpdateDialog = ({ visible, versionInfo, onUpdateNow, onRemindLater }) => {
if (!visible) return null;
return (
<div className="update-dialog">
<h2>Update Available!</h2>
<p>Version {versionInfo.latestVersion} is now available</p>
<button onClick={onUpdateNow}>Update Now</button>
<button onClick={onRemindLater}>Remind Me Later</button>
</div>
);
};
// App component
function App() {
return (
<VersionCheckProvider
dataProvider={new MyDataProvider()}
storageProvider={new LocalStorageProvider()}
dialogComponent={UpdateDialog}
>
<YourApp />
</VersionCheckProvider>
);
}
// Using the hook in a component
function YourComponent() {
const { isUpdateAvailable, currentVersion, checkForUpdates } = useVersionCheck();
return (
<div>
<p>Current version: {currentVersion}</p>
{isUpdateAvailable && <p>An update is available!</p>}
<button onClick={checkForUpdates}>Check for Updates</button>
</div>
);
}
import React from 'react';
import { VersionCheckProvider, useAppStateVersionCheck } from 'app-version-checker/react';
import { AsyncStorageProvider } from 'app-version-checker/stores';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AppState, Linking } from 'react-native';
// Create providers
const storageProvider = new AsyncStorageProvider(AsyncStorage);
function App() {
const handleOpenStore = async (url) => {
const supported = await Linking.canOpenURL(url);
if (supported) {
await Linking.openURL(url);
}
};
return (
<VersionCheckProvider
dataProvider={new MyDataProvider()}
storageProvider={storageProvider}
onOpenStore={handleOpenStore}
checkOnForeground={true}
>
<AppContent />
</VersionCheckProvider>
);
}
// Use app state checking
function AppContent() {
// Automatically check when app comes to foreground
useAppStateVersionCheck(AppState, true);
return <YourApp />;
}
Implement IVersionDataProvider to fetch version data from your source:
interface IVersionDataProvider {
getCurrentVersion(): Promise<string> | string;
getLatestVersion(platform: Platform): Promise<string | null>;
getAppStoreConfig(): Promise<AppStoreConfig> | AppStoreConfig;
// Optional methods
getCurrentPlatform?(): Platform;
getFormattedVersion?(): Promise<string> | string;
isUpdateMandatory?(currentVersion: string, latestVersion: string): Promise<boolean> | boolean;
getChangeLog?(version: string): Promise<string | null>;
}
Implement IStorageProvider to store preferences:
interface IStorageProvider {
getLastCheckTime(): Promise<number | null>;
setLastCheckTime(timestamp: number): Promise<void>;
getRemindLaterTime(): Promise<number | null>;
setRemindLaterTime(timestamp: number): Promise<void>;
clearRemindLaterTime(): Promise<void>;
// Optional methods
getDismissCount?(): Promise<number>;
incrementDismissCount?(): Promise<void>;
}
See the examples/ folder for sample implementations:
import { compareVersions, isUpdateAvailable } from 'app-version-checker/core';
// Compare versions
compareVersions('1.0.0', '1.0.1'); // Returns -1
compareVersions('2.0.0', '1.9.9'); // Returns 1
compareVersions('1.0.0', '1.0.0'); // Returns 0
// Check if update needed
isUpdateAvailable('1.0.0', '1.0.1'); // Returns true
import { formatVersionWithBuild, parseVersion } from 'app-version-checker/core';
// Format with build number
formatVersionWithBuild('1.0.0', '123'); // Returns '1.0.0.123'
// Parse version
parseVersion('1.2.3.456');
// Returns { major: 1, minor: 2, patch: 3, build: 456 }
import { getStoreUrl } from 'app-version-checker/core';
const url = getStoreUrl('ios', {
iosAppStoreId: '123456789'
});
// Returns: https://apps.apple.com/app/id123456789
Main hook for accessing version check context:
const {
versionInfo, // Current version information
isUpdateAvailable, // Boolean flag
currentVersion, // Current app version
formattedVersion, // Formatted version string
showUpdateDialog, // Dialog visibility state
isChecking, // Loading state
error, // Any errors
checkForUpdates, // Manual check function
handleUpdateNow, // Open app store
handleRemindLater, // Set reminder
} = useVersionCheck();
Check for updates at regular intervals:
usePeriodicVersionCheck(
60 * 60 * 1000, // Check every hour
true // Enabled
);
Check when page becomes visible (web):
useVisibilityVersionCheck(true);
const options = {
// Minimum time between version checks (milliseconds)
minCheckInterval: 60 * 60 * 1000, // Default: 1 hour
// Duration for "remind me later" (milliseconds)
remindLaterDuration: 24 * 60 * 60 * 1000, // Default: 24 hours
// Skip version checking on web platform
skipWebPlatform: true, // Default: true
// Custom platform detection
getPlatform: () => detectPlatform(), // Optional
};
If you have existing version checking code, here's how to migrate:
See examples/migration/ for detailed migration guides.
Check the examples/ directory for:
The package includes utilities for testing:
import { InMemoryStorageProvider } from 'app-version-checker/stores';
// Use in-memory storage for tests
const testStorage = new InMemoryStorageProvider();
// Mock your data provider
const mockDataProvider = {
getCurrentVersion: () => '1.0.0',
getLatestVersion: () => Promise.resolve('2.0.0'),
// ...
};
Full API documentation is available at docs/api.md.
Contributions are welcome! Please read our Contributing Guide for details.
MIT © [Your Name]
See CHANGELOG.md for version history.
FAQs
React App version checking and update prompts for React, React Native, and web applications
The npm package @markvivanco/app-version-checker receives a total of 1 weekly downloads. As such, @markvivanco/app-version-checker popularity was classified as not popular.
We found that @markvivanco/app-version-checker demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.