react-native-config-ultimate 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +476 -121
- package/android/rncu.gradle +19 -15
- package/android/src/main/java/com/reactnativeultimateconfig/UltimateConfigHelper.java +87 -0
- package/android/src/main/java/com/reactnativeultimateconfig/UltimateConfigPackage.java +1 -1
- package/android/src/newarch/java/com/reactnativeultimateconfig/UltimateConfigModule.java +3 -50
- package/android/src/oldarch/java/com/reactnativeultimateconfig/UltimateConfigModule.java +3 -54
- package/ios/UltimateConfig.mm +2 -1
- package/lib/commonjs/cli.js +10 -4
- package/lib/commonjs/cli.js.map +1 -1
- package/lib/commonjs/flatten.js +6 -1
- package/lib/commonjs/flatten.js.map +1 -1
- package/lib/commonjs/load-env.js +14 -0
- package/lib/commonjs/load-env.js.map +1 -1
- package/lib/commonjs/main.js +5 -1
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/render-env.js +1 -1
- package/lib/commonjs/render-env.js.map +1 -1
- package/lib/commonjs/resolve-env.js +5 -1
- package/lib/commonjs/resolve-env.js.map +1 -1
- package/lib/commonjs/templates/override.js.handlebars +1 -10
- package/lib/commonjs/validate-env.js +20 -7
- package/lib/commonjs/validate-env.js.map +1 -1
- package/lib/module/cli.js +10 -4
- package/lib/module/cli.js.map +1 -1
- package/lib/module/flatten.js +6 -1
- package/lib/module/flatten.js.map +1 -1
- package/lib/module/load-env.js +14 -0
- package/lib/module/load-env.js.map +1 -1
- package/lib/module/main.js +6 -2
- package/lib/module/main.js.map +1 -1
- package/lib/module/render-env.js +1 -1
- package/lib/module/render-env.js.map +1 -1
- package/lib/module/resolve-env.js +5 -1
- package/lib/module/resolve-env.js.map +1 -1
- package/lib/module/templates/override.js.handlebars +1 -10
- package/lib/module/validate-env.js +19 -7
- package/lib/module/validate-env.js.map +1 -1
- package/lib/typescript/src/cli.d.ts.map +1 -1
- package/lib/typescript/src/flatten.d.ts.map +1 -1
- package/lib/typescript/src/load-env.d.ts.map +1 -1
- package/lib/typescript/src/main.d.ts +1 -1
- package/lib/typescript/src/main.d.ts.map +1 -1
- package/lib/typescript/src/render-env.d.ts.map +1 -1
- package/lib/typescript/src/resolve-env.d.ts +8 -1
- package/lib/typescript/src/resolve-env.d.ts.map +1 -1
- package/lib/typescript/src/validate-env.d.ts +8 -0
- package/lib/typescript/src/validate-env.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/cli.ts +11 -4
- package/src/flatten.ts +6 -1
- package/src/load-env.ts +18 -0
- package/src/main.ts +6 -2
- package/src/render-env.ts +4 -1
- package/src/resolve-env.ts +16 -2
- package/src/templates/override.js.handlebars +1 -10
- package/src/validate-env.ts +23 -7
- package/lib/commonjs/bin.spec.js +0 -48
- package/lib/commonjs/bin.spec.js.map +0 -1
- package/lib/commonjs/cli.spec.js +0 -190
- package/lib/commonjs/cli.spec.js.map +0 -1
- package/lib/commonjs/flatten.spec.js +0 -32
- package/lib/commonjs/flatten.spec.js.map +0 -1
- package/lib/commonjs/load-env.spec.js +0 -257
- package/lib/commonjs/load-env.spec.js.map +0 -1
- package/lib/commonjs/main.spec.js +0 -228
- package/lib/commonjs/main.spec.js.map +0 -1
- package/lib/commonjs/render-env.spec.js +0 -397
- package/lib/commonjs/render-env.spec.js.map +0 -1
- package/lib/commonjs/resolve-env.spec.js +0 -31
- package/lib/commonjs/resolve-env.spec.js.map +0 -1
- package/lib/commonjs/validate-env.spec.js +0 -325
- package/lib/commonjs/validate-env.spec.js.map +0 -1
- package/lib/commonjs/write-env.spec.js +0 -115
- package/lib/commonjs/write-env.spec.js.map +0 -1
- package/lib/module/bin.spec.js +0 -47
- package/lib/module/bin.spec.js.map +0 -1
- package/lib/module/cli.spec.js +0 -190
- package/lib/module/cli.spec.js.map +0 -1
- package/lib/module/flatten.spec.js +0 -31
- package/lib/module/flatten.spec.js.map +0 -1
- package/lib/module/load-env.spec.js +0 -257
- package/lib/module/load-env.spec.js.map +0 -1
- package/lib/module/main.spec.js +0 -224
- package/lib/module/main.spec.js.map +0 -1
- package/lib/module/render-env.spec.js +0 -396
- package/lib/module/render-env.spec.js.map +0 -1
- package/lib/module/resolve-env.spec.js +0 -30
- package/lib/module/resolve-env.spec.js.map +0 -1
- package/lib/module/validate-env.spec.js +0 -325
- package/lib/module/validate-env.spec.js.map +0 -1
- package/lib/module/write-env.spec.js +0 -115
- package/lib/module/write-env.spec.js.map +0 -1
- package/lib/typescript/src/bin.spec.d.ts +0 -2
- package/lib/typescript/src/bin.spec.d.ts.map +0 -1
- package/lib/typescript/src/cli.spec.d.ts +0 -14
- package/lib/typescript/src/cli.spec.d.ts.map +0 -1
- package/lib/typescript/src/flatten.spec.d.ts +0 -2
- package/lib/typescript/src/flatten.spec.d.ts.map +0 -1
- package/lib/typescript/src/load-env.spec.d.ts +0 -6
- package/lib/typescript/src/load-env.spec.d.ts.map +0 -1
- package/lib/typescript/src/main.spec.d.ts +0 -2
- package/lib/typescript/src/main.spec.d.ts.map +0 -1
- package/lib/typescript/src/render-env.spec.d.ts +0 -2
- package/lib/typescript/src/render-env.spec.d.ts.map +0 -1
- package/lib/typescript/src/resolve-env.spec.d.ts +0 -2
- package/lib/typescript/src/resolve-env.spec.d.ts.map +0 -1
- package/lib/typescript/src/validate-env.spec.d.ts +0 -2
- package/lib/typescript/src/validate-env.spec.d.ts.map +0 -1
- package/lib/typescript/src/write-env.spec.d.ts +0 -9
- package/lib/typescript/src/write-env.spec.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,150 +1,505 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/logo.svg" alt="react-native-config-ultimate logo" width="100" height="100" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<h1 align="center">react-native-config-ultimate</h1>
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
<strong>Environment variables for React Native that just work.</strong>
|
|
9
|
+
<br />
|
|
10
|
+
<strong>iOS</strong> • <strong>Android</strong> • <strong>Web</strong> • <strong>Old & New Architecture</strong>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://www.npmjs.com/package/react-native-config-ultimate">
|
|
15
|
+
<img src="https://img.shields.io/npm/v/react-native-config-ultimate?style=flat-square&color=CC3534&label=npm" alt="npm version" />
|
|
16
|
+
</a>
|
|
17
|
+
<a href="https://www.npmjs.com/package/react-native-config-ultimate">
|
|
18
|
+
<img src="https://img.shields.io/npm/dm/react-native-config-ultimate?style=flat-square&color=007ACC&label=downloads" alt="npm downloads" />
|
|
19
|
+
</a>
|
|
20
|
+
<a href="./LICENSE">
|
|
21
|
+
<img src="https://img.shields.io/npm/l/react-native-config-ultimate?style=flat-square&color=brightgreen" alt="license" />
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://www.typescriptlang.org/">
|
|
24
|
+
<img src="https://img.shields.io/badge/TypeScript-strict-3178C6?style=flat-square" alt="TypeScript" />
|
|
25
|
+
</a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="./docs/quickstart.md"><strong>Getting Started</strong></a> •
|
|
30
|
+
<a href="./docs/api.md"><strong>API Reference</strong></a> •
|
|
31
|
+
<a href="./docs/cookbook.md"><strong>Cookbook</strong></a> •
|
|
32
|
+
<a href="https://github.com/javier545dev/react-native-config-ultimate/issues"><strong>Report Bug</strong></a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## The Problem
|
|
38
|
+
|
|
39
|
+
Managing environment variables in React Native is painful:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
❌ Different config files for iOS and Android
|
|
43
|
+
❌ Separate setup for each platform
|
|
44
|
+
❌ Type-unsafe string values
|
|
45
|
+
❌ No support for New Architecture
|
|
46
|
+
❌ Existing solutions are unmaintained
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## The Solution
|
|
50
|
+
|
|
51
|
+
**One config file. Every platform. Type-safe. Just works.**
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Create your config
|
|
55
|
+
echo "API_URL=https://api.myapp.com" > .env
|
|
56
|
+
|
|
57
|
+
# Generate for all platforms
|
|
58
|
+
npx rncu .env
|
|
59
|
+
|
|
60
|
+
# Use everywhere ✨
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import Config from 'react-native-config-ultimate';
|
|
65
|
+
|
|
66
|
+
// TypeScript knows your config shape!
|
|
67
|
+
console.log(Config.API_URL); // https://api.myapp.com
|
|
68
|
+
```
|
|
8
69
|
|
|
9
70
|
---
|
|
10
71
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
>
|
|
14
|
-
>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
>
|
|
19
|
-
>
|
|
20
|
-
>
|
|
21
|
-
|
|
72
|
+
## Why Choose This Library?
|
|
73
|
+
|
|
74
|
+
<table>
|
|
75
|
+
<tr>
|
|
76
|
+
<th width="33%">🚀 Modern</th>
|
|
77
|
+
<th width="33%">📱 Universal</th>
|
|
78
|
+
<th width="33%">🛡️ Type-Safe</th>
|
|
79
|
+
</tr>
|
|
80
|
+
<tr>
|
|
81
|
+
<td>
|
|
82
|
+
|
|
83
|
+
- New Architecture ready
|
|
84
|
+
- TurboModules support
|
|
85
|
+
- React Native 0.73+
|
|
86
|
+
- React 18 & 19
|
|
87
|
+
|
|
88
|
+
</td>
|
|
89
|
+
<td>
|
|
90
|
+
|
|
91
|
+
- iOS (Swift, Obj-C)
|
|
92
|
+
- Android (Kotlin, Java)
|
|
93
|
+
- Web (RN Web, Vite)
|
|
94
|
+
|
|
95
|
+
</td>
|
|
96
|
+
<td>
|
|
97
|
+
|
|
98
|
+
- Auto-generated `.d.ts`
|
|
99
|
+
- Strict TypeScript
|
|
100
|
+
- Schema validation
|
|
101
|
+
- Zero `any` types
|
|
102
|
+
|
|
103
|
+
</td>
|
|
104
|
+
</tr>
|
|
105
|
+
</table>
|
|
106
|
+
|
|
107
|
+
### Comparison
|
|
108
|
+
|
|
109
|
+
| Feature | react-native-config-ultimate | react-native-config | react-native-dotenv |
|
|
110
|
+
|---------|:----------------------------:|:-------------------:|:-------------------:|
|
|
111
|
+
| **New Architecture** | ✅ | ❌ | ❌ |
|
|
112
|
+
| **React Native 0.79+** | ✅ | ⚠️ | ⚠️ |
|
|
113
|
+
| **Web support** | ✅ | ❌ | ✅ |
|
|
114
|
+
| **YAML config** | ✅ | ❌ | ❌ |
|
|
115
|
+
| **Per-platform values** | ✅ | ❌ | ❌ |
|
|
116
|
+
| **Type-safe** | ✅ | ⚠️ | ⚠️ |
|
|
117
|
+
| **Multi-env merging** | ✅ | ❌ | ❌ |
|
|
118
|
+
| **Schema validation** | ✅ | ❌ | ❌ |
|
|
119
|
+
| **Native code access** | ✅ | ✅ | ❌ |
|
|
120
|
+
| **Active maintenance** | ✅ | ⚠️ | ⚠️ |
|
|
22
121
|
|
|
23
122
|
---
|
|
24
123
|
|
|
25
|
-
##
|
|
124
|
+
## Quick Start
|
|
125
|
+
|
|
126
|
+
### 1. Install
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
npm install react-native-config-ultimate
|
|
130
|
+
# or
|
|
131
|
+
yarn add react-native-config-ultimate
|
|
132
|
+
# or
|
|
133
|
+
pnpm add react-native-config-ultimate
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### 2. Create config file
|
|
26
137
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
138
|
+
**Option A: `.env` (simple)**
|
|
139
|
+
```bash
|
|
140
|
+
API_URL=https://api.myapp.com
|
|
141
|
+
APP_NAME=MyApp
|
|
142
|
+
DEBUG_MODE=true
|
|
143
|
+
VERSION=1.0.0
|
|
144
|
+
```
|
|
30
145
|
|
|
31
|
-
|
|
146
|
+
**Option B: `.env.yaml` (powerful)**
|
|
147
|
+
```yaml
|
|
148
|
+
API_URL: https://api.myapp.com
|
|
149
|
+
APP_NAME: MyApp
|
|
150
|
+
DEBUG_MODE: true
|
|
151
|
+
VERSION: 1.0.0
|
|
32
152
|
|
|
33
|
-
|
|
153
|
+
# Per-platform values 🎯
|
|
154
|
+
APP_ICON:
|
|
155
|
+
ios: AppIcon
|
|
156
|
+
android: ic_launcher
|
|
157
|
+
```
|
|
34
158
|
|
|
35
|
-
|
|
36
|
-
| ---------------------------- | ------------ | ------ | ---------------- |
|
|
37
|
-
| 0.0.x | >=0.73 | >=18 | ✅ TurboModules |
|
|
159
|
+
### 3. Setup native projects
|
|
38
160
|
|
|
39
|
-
|
|
161
|
+
📱 **iOS** — [Setup Guide](./docs/quickstart.md#ios-setup)
|
|
162
|
+
🤖 **Android** — [Setup Guide](./docs/quickstart.md#android-setup)
|
|
40
163
|
|
|
41
|
-
|
|
42
|
-
| npm | yarn |
|
|
43
|
-
|-|-|
|
|
44
|
-
|`npm install react-native-config-ultimate` | `yarn add react-native-config-ultimate`|
|
|
45
|
-
2. [one-off setup for native projects](./docs/quickstart.md)
|
|
46
|
-
3. initialize env
|
|
47
|
-
| npm | yarn |
|
|
48
|
-
|-|-|
|
|
49
|
-
|`npx rncu .env`|`yarn rncu .env`|
|
|
50
|
-
4. build! `react-native run-{ios,android}`
|
|
164
|
+
### 4. Generate & use
|
|
51
165
|
|
|
52
|
-
|
|
166
|
+
```bash
|
|
167
|
+
npx rncu .env
|
|
168
|
+
# or
|
|
169
|
+
npx rncu .env.yaml
|
|
170
|
+
```
|
|
53
171
|
|
|
54
|
-
|
|
55
|
-
|
|
172
|
+
```tsx
|
|
173
|
+
import Config from 'react-native-config-ultimate';
|
|
56
174
|
|
|
57
|
-
|
|
175
|
+
function App() {
|
|
176
|
+
return (
|
|
177
|
+
<View>
|
|
178
|
+
<Text>API: {Config.API_URL}</Text>
|
|
179
|
+
<Text>Version: {Config.VERSION}</Text>
|
|
180
|
+
{Config.DEBUG_MODE && <Text>🐛 Debug Mode</Text>}
|
|
181
|
+
</View>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
```
|
|
58
185
|
|
|
59
|
-
|
|
186
|
+
**That's it!** Full guide: [**Quickstart →**](./docs/quickstart.md)
|
|
60
187
|
|
|
61
|
-
|
|
62
|
-
1. [Mission 🥾](#mission)
|
|
63
|
-
1. [Quickstart Guide 🏃](./docs/quickstart.md)
|
|
64
|
-
1. [Migration Guide 🚀](./docs/migration.md) — from `react-native-ultimate-config` or `react-native-config`
|
|
65
|
-
1. [API 🧰](./docs/api.md)
|
|
66
|
-
1. [Testing Guide 🧪](./docs/testing.md)
|
|
67
|
-
1. [Cookbook 🥦](./docs/cookbook.md)
|
|
68
|
-
1. [Troubleshooting 🎱](./docs/troubleshooting.md)
|
|
69
|
-
1. [Contributing 🤝](./CONTRIBUTING.md)
|
|
70
|
-
1. [Alternatives](./docs/alternatives.md)
|
|
188
|
+
---
|
|
71
189
|
|
|
72
190
|
## Features
|
|
73
191
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
192
|
+
<details>
|
|
193
|
+
<summary><strong>📁 Multi-Environment Support</strong></summary>
|
|
194
|
+
|
|
195
|
+
Merge multiple env files — great for staging, production, etc:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
npx rncu .env.base .env.staging
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Later values override earlier ones.
|
|
202
|
+
|
|
203
|
+
</details>
|
|
204
|
+
|
|
205
|
+
<details>
|
|
206
|
+
<summary><strong>🔗 Variable Expansion</strong></summary>
|
|
207
|
+
|
|
208
|
+
Reference other variables:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
BASE_URL=https://api.myapp.com
|
|
212
|
+
API_URL=$BASE_URL/v1
|
|
213
|
+
AUTH_URL=$BASE_URL/auth
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
</details>
|
|
217
|
+
|
|
218
|
+
<details>
|
|
219
|
+
<summary><strong>✅ Schema Validation</strong></summary>
|
|
220
|
+
|
|
221
|
+
Fail fast if required vars are missing:
|
|
222
|
+
|
|
223
|
+
```js
|
|
224
|
+
// .rncurc.js
|
|
225
|
+
module.exports = {
|
|
226
|
+
schema: {
|
|
227
|
+
API_URL: { type: 'string', required: true },
|
|
228
|
+
DEBUG_MODE: { type: 'boolean', default: false },
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
</details>
|
|
234
|
+
|
|
235
|
+
<details>
|
|
236
|
+
<summary><strong>🎯 Per-Platform Values</strong></summary>
|
|
237
|
+
|
|
238
|
+
Different values for iOS/Android/Web:
|
|
239
|
+
|
|
240
|
+
```yaml
|
|
241
|
+
APP_STORE_URL:
|
|
242
|
+
ios: https://apps.apple.com/app/myapp
|
|
243
|
+
android: https://play.google.com/store/apps/details?id=com.myapp
|
|
244
|
+
web: https://myapp.com
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
</details>
|
|
248
|
+
|
|
249
|
+
<details>
|
|
250
|
+
<summary><strong>🪝 Hooks API</strong></summary>
|
|
251
|
+
|
|
252
|
+
Transform values at build time:
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
// .rncurc.js
|
|
256
|
+
module.exports = {
|
|
257
|
+
on_env: (env) => ({
|
|
258
|
+
...env,
|
|
259
|
+
BUILD_TIME: new Date().toISOString(),
|
|
260
|
+
})
|
|
261
|
+
};
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
</details>
|
|
265
|
+
|
|
266
|
+
<details>
|
|
267
|
+
<summary><strong>👀 Watch Mode</strong></summary>
|
|
268
|
+
|
|
269
|
+
Auto-regenerate on changes:
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
npx rncu .env --watch
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
</details>
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## How It Works
|
|
280
|
+
|
|
281
|
+
```mermaid
|
|
282
|
+
flowchart TB
|
|
283
|
+
subgraph Config["📄 Configuration"]
|
|
284
|
+
ENV[".env"]
|
|
285
|
+
YAML[".env.yaml"]
|
|
286
|
+
SCHEMA[".rncurc.js"]
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
subgraph Build["🔧 Build Time"]
|
|
290
|
+
CLI["npx rncu"]
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
subgraph Generated["📦 Generated Files"]
|
|
294
|
+
TS["env.ts + index.d.ts"]
|
|
295
|
+
XCCONFIG["rncu.xcconfig"]
|
|
296
|
+
KT["RNCUValues.kt"]
|
|
297
|
+
end
|
|
298
|
+
|
|
299
|
+
subgraph iOS["🍎 iOS"]
|
|
300
|
+
SWIFT["Swift"]
|
|
301
|
+
OBJC["Objective-C"]
|
|
302
|
+
PLIST["Info.plist"]
|
|
303
|
+
XCODE["Build Settings"]
|
|
304
|
+
end
|
|
305
|
+
|
|
306
|
+
subgraph Android["🤖 Android"]
|
|
307
|
+
KOTLIN["Kotlin"]
|
|
308
|
+
JAVA["Java"]
|
|
309
|
+
MANIFEST["AndroidManifest"]
|
|
310
|
+
GRADLE["build.gradle"]
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
subgraph Web["🌐 Web"]
|
|
314
|
+
VITE["Vite"]
|
|
315
|
+
WEBPACK["Webpack"]
|
|
316
|
+
RNW["React Native Web"]
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
subgraph JS["⚛️ JavaScript"]
|
|
320
|
+
REACT["React Components"]
|
|
321
|
+
HOOKS["Custom Hooks"]
|
|
322
|
+
SERVICES["API Services"]
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
ENV --> CLI
|
|
326
|
+
YAML --> CLI
|
|
327
|
+
SCHEMA --> CLI
|
|
328
|
+
|
|
329
|
+
CLI --> TS
|
|
330
|
+
CLI --> XCCONFIG
|
|
331
|
+
CLI --> KT
|
|
332
|
+
|
|
333
|
+
TS --> JS
|
|
334
|
+
TS --> Web
|
|
335
|
+
|
|
336
|
+
XCCONFIG --> iOS
|
|
337
|
+
KT --> Android
|
|
338
|
+
|
|
339
|
+
style Config fill:#e3f2fd
|
|
340
|
+
style Build fill:#fff8e1
|
|
341
|
+
style Generated fill:#e8f5e9
|
|
342
|
+
style iOS fill:#fafafa
|
|
343
|
+
style Android fill:#e8f5e9
|
|
344
|
+
style Web fill:#e1f5fe
|
|
345
|
+
style JS fill:#fce4ec
|
|
346
|
+
```
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Access Everywhere
|
|
352
|
+
|
|
353
|
+
Your config is available in every layer of your app:
|
|
354
|
+
|
|
355
|
+
| Layer | iOS | Android |
|
|
356
|
+
|:------|:----|:--------|
|
|
357
|
+
| **JavaScript / TypeScript** | `Config.API_URL` | `Config.API_URL` |
|
|
358
|
+
| **Native Code** | `UltimateConfig.API_URL` (Swift / Obj-C) | `BuildConfig.API_URL` (Kotlin / Java) |
|
|
359
|
+
| **Build Settings** | `$(API_URL)` — Xcode Build Settings, Info.plist | `${API_URL}` — AndroidManifest.xml, build.gradle |
|
|
360
|
+
|
|
361
|
+
**Examples:**
|
|
362
|
+
|
|
363
|
+
```swift
|
|
364
|
+
// Swift
|
|
365
|
+
let apiUrl = UltimateConfig.API_URL
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
```kotlin
|
|
369
|
+
// Kotlin
|
|
370
|
+
val apiUrl = BuildConfig.API_URL
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
```xml
|
|
374
|
+
<!-- AndroidManifest.xml -->
|
|
375
|
+
<meta-data android:name="api_url" android:value="${API_URL}" />
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
---
|
|
379
|
+
|
|
380
|
+
## Compatibility
|
|
381
|
+
|
|
382
|
+
| Version | React Native | React | Gradle | Architecture |
|
|
383
|
+
|:-------:|:------------:|:-----:|:------:|:------------:|
|
|
384
|
+
| **0.2.x** | ≥ 0.73 | ≥ 18 | ≥ 8 | ✅ New (TurboModules) |
|
|
385
|
+
|
|
386
|
+
> **Need older RN support?** See [`react-native-ultimate-config`](https://github.com/maxkomarychev/react-native-ultimate-config)
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## Documentation
|
|
391
|
+
|
|
392
|
+
| 📖 Guide | Description |
|
|
393
|
+
|:---------|:------------|
|
|
394
|
+
| [**Quickstart**](./docs/quickstart.md) | Installation and setup |
|
|
395
|
+
| [**API Reference**](./docs/api.md) | JavaScript, native code, build tools |
|
|
396
|
+
| [**Migration Guide**](./docs/migration.md) | From react-native-config |
|
|
397
|
+
| [**Cookbook**](./docs/cookbook.md) | Common patterns and recipes |
|
|
398
|
+
| [**Testing**](./docs/testing.md) | Mocking Config in tests |
|
|
399
|
+
| [**Monorepo Tips**](./docs/monorepo-tips.md) | pnpm, yarn workspaces, Lerna |
|
|
400
|
+
| [**Troubleshooting**](./docs/troubleshooting.md) | Common issues and solutions |
|
|
401
|
+
|
|
402
|
+
---
|
|
403
|
+
|
|
404
|
+
## Examples
|
|
405
|
+
|
|
406
|
+
| Project | React Native | Platforms | Description |
|
|
407
|
+
|:--------|:------------:|:---------:|:------------|
|
|
408
|
+
| [**example**](./packages/example) | 0.83 | iOS, Android | Full native app with YAML |
|
|
409
|
+
| [**Example079**](./packages/Example079) | 0.79 | iOS, Android, Web | Native + Vite web |
|
|
410
|
+
| [**example-web**](./packages/example-web) | — | Web | Standalone Vite + RN Web |
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## Frequently Asked Questions
|
|
415
|
+
|
|
416
|
+
<details>
|
|
417
|
+
<summary><strong>Do I need to rebuild after changing .env?</strong></summary>
|
|
418
|
+
|
|
419
|
+
**JavaScript**: No, just re-run `npx rncu .env` and reload the app.
|
|
420
|
+
|
|
421
|
+
**Native values** (Info.plist, AndroidManifest): Yes, you need to rebuild.
|
|
422
|
+
|
|
423
|
+
</details>
|
|
424
|
+
|
|
425
|
+
<details>
|
|
426
|
+
<summary><strong>How do I use different configs for dev/staging/prod?</strong></summary>
|
|
427
|
+
|
|
428
|
+
Use multi-file merging:
|
|
429
|
+
```bash
|
|
430
|
+
npx rncu .env.base .env.production
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Or use separate commands in your package.json:
|
|
434
|
+
```json
|
|
435
|
+
{
|
|
436
|
+
"scripts": {
|
|
437
|
+
"env:dev": "rncu .env.dev",
|
|
438
|
+
"env:prod": "rncu .env.prod"
|
|
439
|
+
}
|
|
440
|
+
}
|
|
138
441
|
```
|
|
139
442
|
|
|
443
|
+
</details>
|
|
444
|
+
|
|
445
|
+
<details>
|
|
446
|
+
<summary><strong>Is this library actively maintained?</strong></summary>
|
|
447
|
+
|
|
448
|
+
Yes! This is a community fork that adds New Architecture support, React 19 compatibility, and ongoing maintenance. See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
|
449
|
+
|
|
450
|
+
</details>
|
|
451
|
+
|
|
140
452
|
---
|
|
141
453
|
|
|
142
|
-
##
|
|
454
|
+
## Contributing
|
|
455
|
+
|
|
456
|
+
We welcome contributions! See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
457
|
+
|
|
458
|
+
```bash
|
|
459
|
+
git clone https://github.com/javier545dev/react-native-config-ultimate.git
|
|
460
|
+
cd react-native-config-ultimate
|
|
461
|
+
pnpm install
|
|
462
|
+
pnpm test
|
|
463
|
+
pnpm build
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
---
|
|
143
467
|
|
|
144
|
-
|
|
468
|
+
## Credits
|
|
469
|
+
|
|
470
|
+
<table>
|
|
471
|
+
<tr>
|
|
472
|
+
<td align="center">
|
|
473
|
+
<strong>Original Author</strong><br/>
|
|
474
|
+
<a href="https://github.com/maxkomarychev">Max Komarychev</a><br/>
|
|
475
|
+
<sub>Creator of react-native-ultimate-config</sub>
|
|
476
|
+
</td>
|
|
477
|
+
<td align="center">
|
|
478
|
+
<strong>Current Maintainer</strong><br/>
|
|
479
|
+
<a href="https://github.com/javier545dev">javier545dev</a><br/>
|
|
480
|
+
<sub>New Architecture & React 19 support</sub>
|
|
481
|
+
</td>
|
|
482
|
+
</tr>
|
|
483
|
+
</table>
|
|
484
|
+
|
|
485
|
+
> This is a community-maintained fork of [`react-native-ultimate-config`](https://github.com/maxkomarychev/react-native-ultimate-config). Full credit to Max for the original design and years of maintenance. The MIT license is preserved.
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## License
|
|
490
|
+
|
|
491
|
+
MIT License — see [LICENSE](./LICENSE) for details.
|
|
492
|
+
|
|
493
|
+
---
|
|
145
494
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
495
|
+
<p align="center">
|
|
496
|
+
<strong>If this library helps you, consider giving it a ⭐️</strong>
|
|
497
|
+
<br/><br/>
|
|
498
|
+
<a href="https://github.com/javier545dev/react-native-config-ultimate">
|
|
499
|
+
<img src="https://img.shields.io/github/stars/javier545dev/react-native-config-ultimate?style=social" alt="GitHub stars" />
|
|
500
|
+
</a>
|
|
501
|
+
</p>
|
|
149
502
|
|
|
150
|
-
|
|
503
|
+
<p align="center">
|
|
504
|
+
<a href="./docs/quickstart.md"><strong>Get Started →</strong></a>
|
|
505
|
+
</p>
|