AI Prompt
Add bundle version checking to my app using the Despia SDK from: https://www.npmjs.com/package/despia-native
First, install the package:Please follow the installation instructions for the
First, install the package:
npm install despia-nativeThen import it: import despia from 'despia-native'- Access the current bundle version using
despia.bundleNumber. This value is automatically available at runtime, no async call is needed - The bundle version uses the format
MAJOR.MINOR.PATCH(e.g.1.0.1,2.7.8) and is set in Despia > Settings > Versioning - Define the minimum required version as a constant using the same format
- Use a semantic version comparison function to compare
despia.bundleNumberagainst your minimum required version. Do not compare version strings directly - If the installed version is below the minimum, show an update prompt. If it meets the requirement, show the feature as normal
This feature requires native capabilities which will be fully provided by the “despia-native” npm package, no additional native libraries are needed!
despia-native npm package closely, and do not modify my instructions. Implementation as mentioned is critical.despia.bundleNumber reflects the native binary version currently installed on the user’s device. By comparing it against a minimum required version, your app can detect whether the user has received a specific binary update and respond accordingly, prompting older users to update while showing the new capability to users who are already on the latest version. despia.bundleNumber is injected by the Despia runtime before your app starts, so it is available synchronously with no async call, no loading state, and no flash of incorrect content.
The Difference
Changes made in Despia affect the native binary. This includes adding a native SDK, updating permissions, or changing entitlements. These changes require a rebuild and a new submission to the app stores. Users must download the update before the new native capability is available on their device. Changes made to your web app via your IDE, no-code tool, or any other coding environment affect the web layer. These are delivered over the air automatically. No rebuild is needed and users receive them silently in the background without having to take any action.Installation
Usage
Reading the Bundle Version
Version Comparison
Do not compare version strings directly, as string comparison does not handle semantic versioning correctly. Use the following utility instead.Gating a Feature by Bundle Version
React
Becausedespia.bundleNumber is available synchronously, you can evaluate the version check outside your component. The correct UI is rendered immediately on first paint with no loading state required.
When to Increment the Bundle Version
Increment the bundle version in Despia > Settings > Versioning whenever your change in Despia requires a new native binary. Changes made to your web app are delivered over the air and do not require a version increment.| Change | Requires New Binary |
|---|---|
| New native SDK added in Despia | Yes |
| New permissions or entitlements in Despia | Yes |
| Web app code update | No |
| Web-layer bug fix | No |
OTA Updates
Every change you make to your web app is delivered over the air. No rebuild, no app store submission, and no action required from your users. This is the primary update path for the majority of changes you will make to your app. Native features exposed through the Despia JS SDK are also delivered over the air. The native capability is already compiled into the binary. Your code calls into it via the SDK, and that code lives in your web layer, so it updates instantly like everything else in the editor. Good uses for OTA updates:- Bug fixes and critical patches
- Performance improvements
- UI and copy changes
- A/B testing and phased rollouts
- Adjusting how existing native features are used within your app
If a fix is genuinely critical and the existing experience is broken without it, shipping it as an OTA update is reasonable and generally accepted by both stores. Stores are not punitive when the reasoning is sound and the update can be characterised as a critical fix. Use good judgement: if you can explain it clearly and it serves the user, it is defensible.
Resources
- NPM Package
- View full NPM documentation for additional configuration options