Is there a way to read the contents of app.json
programmatically from within you app, so you could for example get the current version number and show it within an About screen?
Asked
Active
Viewed 1.3k times
28

cseelus
- 1,447
- 1
- 20
- 31
7 Answers
66
You can access this through Constants.manifest
. This includes your app.json config without any of the potentially sensitive information such as API secret keys.
import Constants from 'expo-constants';
Constants.manifest.version

brentvatne
- 7,603
- 4
- 38
- 55
-
1@brentvatne, how can we access version in expo SDK 33, coz I am facing the issue while getting the version. – Arvindlal Jaiswal Jul 12 '19 at 10:44
-
how would you put google map api key in app.js ? I tried to add a googmapkey, it said invalid key – angry kiwi Jul 17 '19 at 20:25
-
@Milean - I updated the code to switch over to using expo-constants – brentvatne May 09 '20 at 18:26
-
3This does not work in SDK 46. – phatmann Aug 17 '22 at 15:54
5
For Expo SDK 35, I did this:
expo install expo-constants
in your .js:
import Constants from "expo-constants";
<Text> {Constants.manifest.description} </Text>

Milean
- 878
- 9
- 16
4
As of Expo SDK 46, use Constants.expoConfig
. Source: https://github.com/expo/expo/discussions/17176

nvbach91
- 166
- 8
3
For expo SDK 33 use:
import Constants from "expo-constants";
{`v${Constants.manifest.version}`}

Arvindlal Jaiswal
- 257
- 2
- 10
3
npm:
npm install expo-constants
OR
expo:
expo install expo-constants
About.js
import Constants from "expo-constants";
<Text>Version {Constants.manifest.version} </Text>

Jay
- 308
- 2
- 10
1
Newer versions of expo (I'm on 36) now import the variable differently
import Constants from 'expo-constants';
Read all about it here on the expo documentation site

Adam Diament
- 4,290
- 3
- 34
- 55
-1
When trying to use this line
import { Constants } from 'expo-constants';
Constants
was showing up as undefined when logged to the console.
However, this code worked to display the app's version:
<template>
<text>version: {{ appVersion }}</text>
</template>
<script>
import * as Constants from 'expo-constants';
export default {
data() {
return {
appVersion: Constants['default']['manifest']['version']
}
}
}
</script>

knot22
- 2,648
- 5
- 31
- 51