|
12 | 12 |
|
13 | 13 | <br /> |
14 | 14 |
|
15 | | -## Features |
16 | | - |
17 | | -- ⚡ **Synchronous access** to version, build number, package name, and country |
18 | | -- 🏪 **Store version lookup** from the App Store or Play Store |
19 | | -- 🔍 **Granular update checks** — major, minor, or patch |
20 | | -- 📦 **Install source detection** — TestFlight, App Store, Play Store, or sideloaded |
21 | | -- 🪶 **Tiny footprint** — pure Swift on iOS, Kotlin on Android |
22 | | - |
23 | | -## Performance |
24 | | - |
25 | | -Benchmarked against [`react-native-version-check`](https://github.com/kimxogus/react-native-version-check). 100,000 iterations averaged over 5 runs on an iPhone 12: |
26 | | - |
27 | | -| Method | Speedup | |
28 | | -|--------|---------| |
29 | | -| `getAllInfo` | **~3.1x faster** | |
30 | | -| `packageName` | **~1.6x faster** | |
31 | | -| `version` | **~1.6x faster** | |
32 | | -| `buildNumber` | **~1.6x faster** | |
33 | | -| `getCountry` | **~3.1x faster** | |
34 | | - |
35 | | -## Installation |
36 | | - |
37 | | -```sh |
38 | | -bun add react-native-nitro-version-check react-native-nitro-modules |
39 | | -``` |
40 | | - |
41 | | -For Expo projects, run prebuild: |
42 | | -```sh |
43 | | -npx expo prebuild |
44 | | -``` |
45 | | - |
46 | | -For bare React Native projects: |
47 | | -```sh |
48 | | -cd ios && pod install |
49 | | -``` |
50 | | - |
51 | | -## Usage |
| 15 | +## Example |
52 | 16 |
|
53 | 17 | ```ts |
54 | | -import { VersionCheck, getCountry, getStoreUrl, getLatestVersion, needsUpdate } from 'react-native-nitro-version-check' |
| 18 | +import { VersionCheck, needsUpdate, getStoreUrl } from 'react-native-nitro-version-check' |
55 | 19 |
|
56 | | -// Sync properties |
| 20 | +// Sync — no bridge, no async |
57 | 21 | VersionCheck.version // "1.2.0" |
58 | 22 | VersionCheck.buildNumber // "42" |
59 | 23 | VersionCheck.packageName // "com.example.app" |
60 | 24 | VersionCheck.installSource // "appstore" | "testflight" | "playstore" | undefined |
61 | | -getCountry() // "US" |
62 | | - |
63 | | -// Async |
64 | | -const url = await getStoreUrl() // App Store / Play Store URL |
65 | | -const latest = await getLatestVersion() // "1.3.0" |
66 | 25 |
|
| 26 | +// Check for updates |
67 | 27 | if (await needsUpdate()) { |
68 | 28 | Linking.openURL(await getStoreUrl()) |
69 | 29 | } |
70 | | - |
71 | | -// Only prompt for major updates |
72 | | -if (await needsUpdate({ level: 'major' })) { |
73 | | - // 1.x → 2.x |
74 | | -} |
75 | 30 | ``` |
76 | 31 |
|
77 | | -## API |
78 | | - |
79 | | -### `VersionCheck` |
80 | | - |
81 | | -| Property | Type | Description | |
82 | | -|----------|------|-------------| |
83 | | -| `version` | `string` | App version | |
84 | | -| `buildNumber` | `string` | Build number | |
85 | | -| `packageName` | `string` | Bundle ID / Application ID | |
86 | | -| `installSource` | `string \| undefined` | `"appstore"` `"testflight"` `"playstore"` or `undefined` | |
87 | | -| `getCountry()` | `string` | Device's 2-letter ISO country code | |
88 | | -| `getStoreUrl()` | `Promise<string>` | App Store / Play Store URL | |
89 | | -| `getLatestVersion()` | `Promise<string>` | Latest version in the store | |
90 | | -| `needsUpdate()` | `Promise<boolean>` | Whether an update is available | |
91 | | - |
92 | | -### Standalone exports |
93 | | - |
94 | | -Also available as individual named exports: |
| 32 | +## Installation |
95 | 33 |
|
96 | | -| Export | Returns | Description | |
97 | | -|--------|---------|-------------| |
98 | | -| `getCountry()` | `string` | Device's 2-letter ISO country code | |
99 | | -| `getStoreUrl()` | `Promise<string>` | App Store / Play Store URL | |
100 | | -| `getLatestVersion()` | `Promise<string>` | Latest version in the store | |
101 | | -| `needsUpdate(options?)` | `Promise<boolean>` | Whether an update is available | |
| 34 | +Install [react-native-nitro-version-check](https://npmjs.org/react-native-nitro-version-check) from npm: |
| 35 | +```sh |
| 36 | +bun add react-native-nitro-version-check react-native-nitro-modules |
| 37 | +cd ios && pod install |
| 38 | +``` |
102 | 39 |
|
103 | | -#### `needsUpdate` options |
| 40 | +## Documentation |
104 | 41 |
|
105 | | -| Option | Type | Default | Description | |
106 | | -|--------|------|---------|-------------| |
107 | | -| `level` | `"major" \| "minor" \| "patch"` | `"patch"` | Minimum version bump to trigger `true` | |
| 42 | +- [**Nitro Version Check** docs 📚](https://alshehriali0.github.io/react-native-nitro-version-check/) |
| 43 | +- [**Getting Started** guide](https://alshehriali0.github.io/react-native-nitro-version-check/docs/getting-started) |
| 44 | +- [**Installation** guide](https://alshehriali0.github.io/react-native-nitro-version-check/docs/installation) |
| 45 | +- [**API Reference**](https://alshehriali0.github.io/react-native-nitro-version-check/docs/api-reference) |
| 46 | +- [**Migration Guide** from react-native-version-check](https://alshehriali0.github.io/react-native-nitro-version-check/docs/migration-guide) |
108 | 47 |
|
109 | | -### Utilities |
| 48 | +## Contributing |
110 | 49 |
|
111 | | -| Function | Returns | Description | |
112 | | -|----------|---------|-------------| |
113 | | -| `compareVersions(v1, v2)` | `-1 \| 0 \| 1` | Compare two semver strings | |
| 50 | +See the [contributing guide](https://alshehriali0.github.io/react-native-nitro-version-check/docs/contributing) to learn how to contribute to the repository and the development workflow. |
114 | 51 |
|
115 | 52 | ## License |
116 | 53 |
|
|
0 commit comments