I've looked on the Lightning Components Developer’s Guide, and I can't seem to find any documentation on how to configure multiple environments for Lightning Components and Apex Controllers.

Ideally, I'd like to be able to specify configuration file which contains the appropriate hostname that I'm using for some REST API calls. Something like:

    hostDomain: 'staging.example.com'
    hostDomain: 'example.com'

Obviously this example is contrived, and the file could well contain other relevant information instead. What I'm wondering is if it's possible, and if so how to do it.

If this isn't possible, then how do Lightning Component developers usually develop components intended for multiple environments? Do they have separate managed packages that they use for test vs production?

3 Answers 3


You might also want to take a look at custom metadata types. These allow you store configuration data in a way that you can include it with your package.

To make this work, define an init handler in your component, which in turn invokes an APEX controller method to retrieve the configuration data. In the callback you can locally store/manage the configuration.


A good practice is probably a custom setting in each organization you are working in. That said, there's no "usually" for lightning component development yet.

  • Thanks for your response. Would you mind outlining how those would work at a high level? If I include a custom setting in a managed package, I'm not sure too sure how much I gain by doing so compared to just hard coding the variable in my apex controller (besides separating my logic a bit more which is indeed cleaner).
    – mralexlau
    Commented Jul 23, 2015 at 14:50

I believe you can make a custom setting in a managed package protected or public, if it is public, the installer of the managed package can change.

  • I can see that working for many scenarios. However in the example I've given, I always want to test against staging.example.com and deploy to production against example.com. What you're suggesting would be for whoever installed the app to change it example.com, right?
    – mralexlau
    Commented Jul 23, 2015 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .