Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read app.json (or exp.json) programmatically

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?

like image 203
cseelus Avatar asked Jul 23 '17 19:07

cseelus


People also ask

What is the use of App JSON?

app. json is a manifest format for describing web apps. It declares environment variables, add-ons, and other information required to run an app on Heroku. This document describes the schema in detail.

What is the use of App JSON in react native?

Because native code can be difficult to maintain, this new script allows an app. json to be defined for the project, which is used to configure the native app.

What is App JSON Expo?

config. js, app. config. ts) is used for configuring how a project loads in Expo Go, Expo Prebuild generation, and the OTA update manifest.


3 Answers

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 
like image 162
brentvatne Avatar answered Oct 22 '22 19:10

brentvatne


For Expo SDK 35, I did this:

expo install expo-constants

in your .js:

import Constants from "expo-constants";

<Text> {Constants.manifest.description} </Text>
like image 42
Milean Avatar answered Oct 22 '22 19:10

Milean


For expo SDK 33 use:

 import Constants from "expo-constants";
 {`v${Constants.manifest.version}`}
like image 3
Arvindlal Jaiswal Avatar answered Oct 22 '22 21:10

Arvindlal Jaiswal