How to set environmental configurations in Meteor

Posted By : Parveen Kumar Yadav | 14-Jul-2016


When we are building app with Meteor, we need to store information like API keys and other configuration information in our application.

We also want different different environmental settings for our app like for development we have diff settings for staging environment we have different URL and keys etc same for Production environment, and that is very important part of any application.

So in this blog I am going to explain you how you can configure diff-diff settings for your app.

You can make your details private and public both by using settings.json file.

Meteor gives us a file name settings.json that is simple json file like:-

  "key": "value"

So we can set our settings in this file as follows:-

1)create a file with name as settings.json in your root directory and fill up this with entry like:-

  "public": {
      "public_key": "gfdrty1212tdbdunoi76445"
    "private_key": "aqewyubdi343bdub087b27b09"

As above i used public so lets understand. In this file whatever you write are not accessible publicly they are private so if you want to use some keys or other as publicly than you need to define keyword public and write all your values under this so these values are accessible publicly. But.But if you want like secret key and other things those are private  just not add public above them.

2)Now you have settings.js file ready so when you start your project with meteor just add:-

meteor --settings settings.json

In this way now your meteor project is running according to your settings which you define in your settings.json

Now just create two more files say stagingSttings.json and productionSettings.json as using the same above steps.

Now enter your staging environmental values into stagingSettings file and for production add your details into productionSettings.json file 

And run with file you want like:-

meteor --settings stagingSettings  // for staging
 meteor --settings productionSettings  // for production

So in this way you can configure your environmental values what you want to be configurable.


About Author

Author Image
Parveen Kumar Yadav

Parveen is an experienced Java Developer working on Java, J2EE, Spring, Hibernate, Grails ,Node.js,Meteor,Blaze, Neo4j, MongoDB, Wowza Streaming Server,FFMPEG,Video transcoding,Amazon web services, AngularJs, javascript. He likes to learn new technologies

Request for Proposal

Name is required

Comment is required

Sending message..