Search⌘ K

The Meteor Settings File

Explore how to configure your Meteor.js applications using the settings file. Understand how to store keys and data in JSON format, differentiate between public and private settings, and learn best practices for loading settings during development and production environments.

The settings file

Meteor provides a way to store information such as keys and configuration data in a JSON file. This JSON file is added to the root of our project. We can call the file whatever we want, but the convention is that it’s usually named settings.json.

A JSON file is a human-readable file that ends in a .JSON file extension. It normally consists of an object with key-value pairs. Meteor exposes the values in the JSON file through the Meteor.settings object. Below is an example of a settings file:

Javascript (babel-node)
{
"googleAPI" : "Qrtgeheh34525262",
"magicNumber" : "0404oio44o4oo4"
}

The values in the settings file can only be accessed at the server. If we want to access it at the client, we should nest a public key in our settings object.

Javascript (babel-node)
{
"public" : {
"clientAPI": "23441990Educative",
"learningSecret": "secret147"
},
"private": {
"googleAnalyticsAPI": "536tyyyyy00hhggg",
"facebookAPI": "yryryyryryry7477474"
}
}

Nesting private and public keys

Keys nested on the public ...