https://github.com/remscodes/react-native-config-info
🔎 Read configuration values from Info.plist (iOS) or from resources strings.xml (Android)
https://github.com/remscodes/react-native-config-info
android configuration ios javascript kotlin objective-c react-native
Last synced: about 1 year ago
JSON representation
🔎 Read configuration values from Info.plist (iOS) or from resources strings.xml (Android)
- Host: GitHub
- URL: https://github.com/remscodes/react-native-config-info
- Owner: remscodes
- License: mit
- Created: 2024-10-29T11:23:53.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-27T10:40:51.000Z (about 1 year ago)
- Last Synced: 2025-04-06T11:02:16.287Z (about 1 year ago)
- Topics: android, configuration, ios, javascript, kotlin, objective-c, react-native
- Language: Kotlin
- Homepage: https://npm.im/react-native-config-info
- Size: 212 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
React Native Config Info
Read configuration values from Info.plist (iOS) or from resources strings.xml (Android)
[](https://github.com/remscodes/react-native-config-info/actions/workflows/npm-ci.yml)
[](https://www.npmjs.org/package/react-native-config-info)
[](https://bundlephobia.com/package/react-native-config-info)
[](LICENSE)
## Installation
```shell
npm install react-native-config-info
cd ios && pod install
```
## Prerequisite
Add your values into your Info.plist (iOS) or strings.xml (Android).
### iOS
_ios/\[project\]/Info.plist_
```text
BackendUrl
https://api.example.com
```
### Android
_android/app/src/main/res/values/strings.xml_
[//]: # (@formatter:off)
```xml
https://api.example.com
```
[//]: # (@formatter:on)
## Usage
### Asynchronous getters
Get your values.
```ts
import ConfigInfo from 'react-native-config-info';
async function main() {
await ConfigInfo.get('BackendUrl'); // https://api.example.com
await ConfigInfo.getOrThrow('BackendUrl'); // https://api.example.com
await ConfigInfo.get('UnknownKey'); // null
await ConfigInfo.getOrThrow('UnknownKey'); // [RNConfigInfoException: 'UnknownKey' value is missing from ….]
}
```
### Synchronous getters
Get your values synchronously.
As said in the official [documentation](https://reactnative.dev/docs/0.70/native-modules-ios#synchronous-methods),
synchronous methods are not recommended.
Only use them if you have no other option.
```ts
import ConfigInfo from 'react-native-config-info';
ConfigInfo.getSync('BackendUrl'); // https://api.example.com
ConfigInfo.getSyncOrThrow('BackendUrl'); // https://api.example.com
ConfigInfo.getSync('UnknownKey'); // null
ConfigInfo.getSyncOrThrow('UnknownKey'); // [RNConfigInfoException: 'UnknownKey' value is missing from ….]
```
## License
[MIT](LICENSE) © Rémy Abitbol.