Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Filipe Névola
Filipe Névola

Posted on

Understanding Meteor's Settings File

Understanding configuration files is essential in the world of Javascript programming andMeteor. You see, typically, most frameworks lack a standard configuration file. Instead, developers use environment variables, which they retrieve when needed. However, Meteor, about ten years ago, chose a different path and decided to introduce a settings file, which essentially transforms into an environment variable in most places.

The Basics of Meteor's Configuration

This unique feature of Meteor allows you to store all configurations in a single JSON. Meteor takes this JSON and transforms it into an environment variable. But there's no magic trick here. Meteor, on its own, loads this JSON into a variable termedMeteor.settings. So, how does it work? Let's explore.

JSON relies on key-value pairs. In the Meteor's settings file, there's a key namedpublic. If you place any configurations within thepublic key, Meteor automatically forwards it to the client. As a result, you can effortlessly access whatever ispublic from the client side.

Understanding Public and Private Segments

However, anything that doesn't fall within thispublic key at the primary level does not reach the client side and remains server-side only. This unique feature is the only "magic" that Meteor performs.

The utility of this settings file from Meteor is that it can also be used to pass configurations to the client side. Usually, passing configurations to the client side warrants extra work since no environmental variables are available on the client side (considering the client side is really the user's browser, and you can't control the user's environment variables).

Think of the settings file as a configuration document that you can use to pass configurations to both the server and the client. However, it's important to distinguish what ispublic (and therefore accessible client-side) and what should stay only on the server.

How to Provide the Settings File to Meteor

It's crucial to provide the settings file correctly to Meteor for effective functioning. To pass these settings to the Meteor application, you must use the--settings parameter. When running your Meteor app, include the settings file as follows:

meteor--settings settings.json
Enter fullscreen modeExit fullscreen mode

In this command, settings.json is the file containing your settings. Notably, the --settings property helps Meteor recognize this file and load the configurations correctly into Meteor.settings, making the configurations available to your application. This way, you can manage server and client configurations within your Meteor application by utilizing the settings file.

Conclusion

Thus, the settings feature of Meteor simplifies a lot of tasks and provides additional ease of use for developers. The settings file is a handy tool, especially for simplifying and managing configurations effectively and efficiently.

Want to try Meteor on the server? TryzCloud. See how to use Meteor settings in zCloudhere.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I'm Filipe Névola, and I'm Quave's CEO, Developer & Instructor trying to be better every day.I'm running zcloud.ws. Experience the flexibility and ease of Cloud hosting with amazing support.
  • Location
    Dourados, MS, Brazil
  • Work
    zCloud & Quave CEO
  • Joined

More fromFilipe Névola

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp