Core

Documentation of core Meteor functions.

If you prefer to watch the video, click below.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 31)

Boolean variable. True if running in client environment.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 39)

Boolean variable. True if running in server environment.

Meteor.isServer can be used to limit where code runs, but it does not prevent code from being sent to the client. Any sensitive code that you don’t want served to the client, such as code containing passwords or authentication mechanisms, should be kept in the server directory.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/cordova_environment.js, line 7)

Boolean variable. True if running in a Cordova mobile environment.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 23)

Boolean variable. True if running in development environment.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 15)

Boolean variable. True if running in production environment.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/startup_client.js, line 70)

Run code when a client or a server starts.

Arguments

func Function

A function to run on startup.

On a server, the function will run as soon as the server process is finished starting. On a client, the function will run as soon as the DOM is ready. Code wrapped in Meteor.startup always runs after all app files have loaded, so you should put code here if you want to access shared variables from other files.

The startup callbacks are called in the same order as the calls to Meteor.startup were made.

On a client, startup callbacks from packages will be called first, followed by <body> templates from your .html files, followed by your application code.

// On server startup, if the database is empty, create some initial data.
if (Meteor.isServer) {
  Meteor.startup(() => {
    if (Rooms.find().count() === 0) {
      Rooms.insert({ name: 'Initial room' });
    }
  });
}
Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/helpers.js, line 133)

Wrap a function that takes a callback function as its final parameter. The signature of the callback of the wrapped function should be function(error, result){}. On the server, the wrapped function can be used either synchronously (without passing a callback) or asynchronously (when a callback is passed). On the client, a callback is always required; errors will be logged if there is no callback. If a callback is provided, the environment captured when the original function was called will be restored in the callback. The parameters of the wrapped function must not contain any optional parameters or be undefined, as the callback function is expected to be the final, non-undefined parameter.

Arguments

func Function

A function that takes a callback as its final parameter

context Object

Optional this object against which the original function will be invoked

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/timers.js, line 84)

Defer execution of a function to run asynchronously in the background (similar to Meteor.setTimeout(func, 0).

Arguments

func Function

The function to run

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/url_common.js, line 10)

Generate an absolute URL pointing to the application. The server reads from the ROOT_URL environment variable to determine where it is running. This is taken care of automatically for apps deployed to Galaxy, but must be provided when using meteor build.

Arguments

path String

A path to append to the root URL. Do not include a leading "/".

Options

secure Boolean

Create an HTTPS URL.

replaceLocalhost Boolean

Replace localhost with 127.0.0.1. Useful for services that don't recognize localhost as a domain name.

rootUrl String

Override the default ROOT_URL from the server environment. For example: "http://foo.example.com"

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 76)

Meteor.settings contains deployment-specific configuration options. You can initialize settings by passing the --settings option (which takes the name of a file containing JSON data) to meteor run or meteor deploy. When running your server directly (e.g. from a bundle), you instead specify settings by putting the JSON directly into the METEOR_SETTINGS environment variable. If the settings object contains a key named public, then Meteor.settings.public will be available on the client as well as the server. All other properties of Meteor.settings are only defined on the server. You can rely on Meteor.settings and Meteor.settings.public being defined objects (not undefined) on both client and server even if there are no settings specified. Changes to Meteor.settings.public at runtime will be picked up by new client connections.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/helpers.js, line 11)

Meteor.release is a string containing the name of the release with which the project was built (for example, "1.2.3"). It is undefined if the project was built using a git checkout of Meteor.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 56)

Boolean variable. True if running in a "modern" JS environment, as determined by the modern package.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/client_environment.js, line 67)

Hexadecimal Git commit hash, if the application is using Git for version control. Undefined otherwise.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/test_environment.js, line 23)

Boolean variable. True when running unit tests (false if running tests in full app mode).

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/test_environment.js, line 32)

Boolean variable. True if running tests against your application i.e meteor test --full-app.

Anywhere
import { Meteor } from 'meteor/meteor'
(meteor/test_environment.js, line 41)

Boolean variable. True if running tests against a Meteor package.

Edit on GitHub
// search box