Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Config Variables for React-Native Apps
Search
Pedro Belo
February 24, 2016
Programming
0
740
Config Variables for React-Native Apps
Pedro Belo
February 24, 2016
Tweet
Share
Other Decks in Programming
See All in Programming
Fluid Templating in TYPO3 14
s2b
0
130
コマンドとリード間の連携に対する脅威分析フレームワーク
pandayumi
1
450
AgentCoreとHuman in the Loop
har1101
5
230
AIで開発はどれくらい加速したのか?AIエージェントによるコード生成を、現場の評価と研究開発の評価の両面からdeep diveしてみる
daisuketakeda
1
2.4k
今から始めるClaude Code超入門
448jp
8
8.6k
なぜSQLはAIぽく見えるのか/why does SQL look AI like
florets1
0
450
OSSとなったswift-buildで Xcodeのビルドを差し替えられるため 自分でXcodeを直せる時代になっている ダイアモンド問題編
yimajo
3
610
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
7.3k
CSC307 Lecture 01
javiergs
PRO
0
690
KIKI_MBSD Cybersecurity Challenges 2025
ikema
0
1.3k
フルサイクルエンジニアリングをAI Agentで全自動化したい 〜構想と現在地〜
kamina_zzz
0
400
インターン生でもAuth0で認証基盤刷新が出来るのか
taku271
0
190
Featured
See All Featured
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
180
From π to Pie charts
rasagy
0
120
Rails Girls Zürich Keynote
gr2m
96
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.7k
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.2k
Faster Mobile Websites
deanohume
310
31k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.3k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
3.9k
How Software Deployment tools have changed in the past 20 years
geshan
0
32k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Documentation Writing (for coders)
carmenintech
77
5.2k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
300
Transcript
Config Variables for React-Native apps
The problem var LuggApi = { request: async function(method, path)
{ let url = 'https://api.lugg.com' + path; let headers = { 'Authorization': 'Bearer 48616d6d65'} let response = await fetch(url, { method, headers }); // ... };
The problem(s) • Secret in repo • Hard to change
• Can’t reuse outside JS
Solving #1 // config.sample.js module.exports = { apiUrl: 'https://api.lugg.com', apiToken:
'CHANGEME' } // api.js var LuggApi = { request: async function(method, path) { let url = Config.apiUrl + path; let headers = { 'Authorization': 'Bearer ' + Config.apiToken } let response = await fetch(url, { method, headers }); // ... };
Solving #2 // config.js var dev = { apiUrl: 'http://localhost:5000',
apiToken: 'abcdefgh' }; var prod = { apiUrl: 'https://api.lugg.com', apiToken: '48616d6d65' }; module.exports = __DEV__ ? dev : prod;
Solving #3 android { productFlavors { dev { resValue "string",
"GOOGLE_MAPS_API_KEY", "abcdefg" } production { resValue "string", "GOOGLE_MAPS_API_KEY", "0123456" } } }
Solving #3
New problems • Inconsistent formats • Need a React Native
bridge • Can’t reuse across platforms
SOLVE ALL THE THINGS $ rnpm install react-native-config
.env API_URL=https://api.lugg.com API_TOKEN=48616d6d65 GOOGLE_MAPS_API_KEY=0123456
Consume from JS import Config from 'react-native-config' Config.API_URL // https://api.lugg.com
Config.API_TOKEN // 48616d6d65
Consume from Gradle android { signingConfigs { release { storeFile
file(project.env.get("RELEASE_STORE_FILE")) storePassword project.env.get("RELEASE_STORE_PASSWORD") keyAlias project.env.get("RELEASE_KEY_ALIAS") keyPassword project.env.get("RELEASE_KEY_PASSWORD") } } }
Consume from AndroidManifest.xml <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/GOOGLE_MAPS_API_KEY" />
Consume from Xcode
Thanks! @ped github.com/luggg/react-native-config