An updated version of this post is up here: Get the App Version with Expo and React Native
This one will be short and sweet.
Most apps show the version number somewhere in the app, usually in the About or Settings screen. I recently wanted to add the ability for my users to see this version number too.
To start with you'll need to install expo-constants which, as the docs state, provides system information that remains constant throughout the lifetime of your app's install.
You can install this by running:
Then importing it wherever you need, probably in the Settings Screen file by adding an import from expo-constants and then you can access the App Version wherever you want by using:
For example, you can grab a Text element and slap the version variable in there like so:
Congrats! You can now access the app version from anywhere within your app.
Just a warning: when testing your app in Expo Go, it will show you the version of Expo Go. This is a common mistake people make, which can lead to a little confusion, as it seems the constant isn't working properly. I'm totally not saying this just because it confused me for a moment.
expo-constants also contains a few other useful things, such as getting the platform your app is running on and the status bar height. You can read more about it here: https://docs.expo.io/versions/latest/sdk/constants/
