Skip to main content

Basic usage

After installing the package, you can immediately access version information synchronously:
1

Import the library

Import VersionCheck from the package:
import { VersionCheck } from 'react-native-nitro-version-check'
2

Access version information

All version properties are available synchronously with zero overhead:
console.log(VersionCheck.version)      // "1.2.0"
console.log(VersionCheck.buildNumber)  // "42"
console.log(VersionCheck.packageName)  // "com.example.app"
These values are cached at module initialization, so repeated access has no performance cost.
3

Display in your UI

Use the version information in your components:
import { Text } from 'react-native'
import { VersionCheck } from 'react-native-nitro-version-check'

export default function App() {
  return (
    <>
      <Text>Version: {VersionCheck.version}</Text>
      <Text>Build: {VersionCheck.buildNumber}</Text>
      <Text>Package: {VersionCheck.packageName}</Text>
      <Text>Country: {VersionCheck.getCountry()}</Text>
      <Text>Install: {VersionCheck.installSource ?? "Dev Build"}</Text>
    </>
  )
}

Check for updates

Use the needsUpdate() function to check if a newer version is available in the store:
1

Import update functions

import { needsUpdate, getStoreUrl } from 'react-native-nitro-version-check'
import { Linking } from 'react-native'
2

Check for updates

Call needsUpdate() to perform a semantic version comparison:
if (await needsUpdate()) {
  const url = await getStoreUrl()
  Linking.openURL(url)
}
This checks if any version increase is available (patch, minor, or major).
3

Filter by update level

You can specify the granularity of updates to check for:
// Only prompt for major updates (1.x → 2.x)
const majorUpdate = await needsUpdate({ level: "major" })

// Check for major or minor updates
const minorUpdate = await needsUpdate({ level: "minor" })

// Check for any update (default)
const anyUpdate = await needsUpdate({ level: "patch" })

Complete example

Here’s a full example showing version display and update checking:
import { useEffect, useState } from 'react'
import { ActivityIndicator, Linking, Text, TouchableOpacity, View } from 'react-native'
import { getLatestVersion, getStoreUrl, needsUpdate, VersionCheck } from 'react-native-nitro-version-check'

export default function App() {
  const [loading, setLoading] = useState(true)
  const [storeUrl, setStoreUrl] = useState<string | null>(null)
  const [latestVersion, setLatestVersion] = useState<string | null>(null)
  const [updateAvailable, setUpdateAvailable] = useState(false)

  useEffect(() => {
    const fetchUpdateInfo = async () => {
      try {
        const [url, latest, hasUpdate] = await Promise.all([
          getStoreUrl(),
          getLatestVersion(),
          needsUpdate()
        ])
        setStoreUrl(url)
        setLatestVersion(latest)
        setUpdateAvailable(hasUpdate)
      } catch (error) {
        console.error('Failed to check for updates:', error)
      }
      setLoading(false)
    }
    fetchUpdateInfo()
  }, [])

  return (
    <View>
      {/* Sync properties — available immediately */}
      <Text>Version: {VersionCheck.version}</Text>
      <Text>Build: {VersionCheck.buildNumber}</Text>
      <Text>Package: {VersionCheck.packageName}</Text>
      <Text>Country: {VersionCheck.getCountry()}</Text>
      <Text>Install: {VersionCheck.installSource ?? "Dev Build"}</Text>

      {/* Async data — shows loading spinner while fetching */}
      {loading ? (
        <ActivityIndicator />
      ) : (
        <>
          <Text>Latest: {latestVersion}</Text>
          <Text>Store URL: {storeUrl}</Text>

          {updateAvailable && storeUrl && (
            <TouchableOpacity onPress={() => Linking.openURL(storeUrl)}>
              <Text>Update available — tap to open store</Text>
            </TouchableOpacity>
          )}

          {!updateAvailable && <Text>App is up to date</Text>}
        </>
      )}
    </View>
  )
}

Install source detection

Detect where your app was installed from:
import { VersionCheck } from 'react-native-nitro-version-check'

if (VersionCheck.installSource === "testflight") {
  console.log("Running a TestFlight build")
} else if (VersionCheck.installSource === "appstore") {
  console.log("Running an App Store build")
} else if (VersionCheck.installSource === "playstore") {
  console.log("Running a Play Store build")
} else {
  console.log("Dev build or sideloaded")
}
Install source is undefined for development builds and sideloaded apps. Use this to show different UI or features based on where the app came from.

TypeScript support

The library is fully typed. Import types for advanced usage:
import type { UpdateLevel } from 'react-native-nitro-version-check'

const checkUpdate = async (level: UpdateLevel) => {
  const hasUpdate = await needsUpdate({ level })
  return hasUpdate
}

Next steps

API reference

Explore all available methods and properties

Migration guide

Migrate from react-native-version-check

Build docs developers (and LLMs) love