Configuration file best practices

Hi guys,
I need to understand the best practices for configure my app. Could you please give me an advice? In java project, for example, we have a properties file. What is the common approach for ionic app? Can I use the ionic.config.json file and access to properties programmatically?


i am interested in this answer too

Ionic.config.json is not available at runtime

You can put your own static version of settings in src/assets as a json file which u retrieve using http. Naming convention of file and folder is up to you

Static Settings that need to be overriden as part of the apps options can be locally stored in localstorage (see ionic storage) or online to an online database like Firebase or any other solution u prefer

ionic storage was the best for me

For configuration, I use a static json object. Super easy to use, available everywhere in my pages and components, available at runtime, no config to make it available and no worries about boot time. There are probably better solution, but I found that handy.

See my example there

P.S.: In java this would be equals to something like a class with static variables

 public class Resources {    
     public static final String API_URL = "https://";

Wrap all the above in a provider

Walk in the park

environment.d.ts is becoming mainstream too.


sure. specially environment.d.ts is a better and cleaner solution to handle configurations reliant on environments (DEV, Prod…)

the pro for static ts file is maybe then that there’s nothing to set up

Arent *.d.ts files meant to be for typescript defintions only and hence fairly empty in terms of logic? Like interfaces or class definitions with no code?

And as such sufficient for that purpose only?

@Tommertom I didn’t try, so I guess @FrancoisIonic will answer better than me

I just had a quick look and found following post about that…

Is there a quick tutorial?