Skip to main content

Meteor Namespace API

The Meteor namespace provides the core API for Meteor applications on both client and server.

User Management

Meteor.userId()

Get the current user id, or null if no user is logged in. A reactive data source. Locus: Anywhere
Reactive Example:

Meteor.user()

Get the current user record, or null if no user is logged in. A reactive data source. Locus: Anywhere
options
object
Optional options object.
options.fields
object
Dictionary of fields to return or exclude.
Note: On the server, Meteor.user() is deprecated. Use Meteor.userAsync() instead.

Meteor.userAsync()

Asynchronously get the current user record, or null if no user is logged in. Locus: Anywhere
options
object
Optional options object.
options.fields
object
Dictionary of fields to return or exclude.

Authentication

Meteor.logout()

Log the user out. Locus: Client
callback
function
Optional callback. Called with no arguments on success, or with a single Error argument on failure.

Meteor.logoutAllClients()

Log out all clients logged in as the current user and logs the current user out as well. Locus: Client

Meteor.logoutOtherClients()

Log out other clients logged in as the current user, but does not log out the client that calls this function. Locus: Client

Meteor.loginWithPassword()

Log the user in with a password. Locus: Client
selector
string | object
required
Either a string interpreted as a username or an email; or an object with a single key: email, username or id. Username or email match in a case insensitive manner.
password
string
required
The user’s password.
callback
function
Optional callback. Called with no arguments on success, or with a single Error argument on failure.

Meteor.loginWithToken()

Login with a Meteor access token. Locus: Client
token
string
required
Local storage token for use with login across multiple tabs in the same browser.
callback
function
Optional callback. Called with no arguments on success.

Connection Management

Meteor.status()

Get the current connection status. A reactive data source. Locus: Client
connected
boolean
True if currently connected to the server.
status
string
Connection status: “connected”, “connecting”, “failed”, “waiting”, or “offline”.
retryCount
number
Number of reconnection attempts made.
retryTime
number
Estimated time of next reconnection attempt.
reason
string
If failed, description of why.

Meteor.reconnect()

Force an immediate reconnection attempt if the client is not connected to the server. Locus: Client

Meteor.disconnect()

Disconnect the client from the server. Locus: Client

Reactive State

Meteor.loggingIn()

True if a login method is currently in progress. A reactive data source. Locus: Client

Meteor.loggingOut()

True if a logout method is currently in progress. A reactive data source. Locus: Client

Server Connection

Meteor.onConnection()

Register a callback to be called when a new DDP connection is made to the server. Locus: Server
callback
function
required
The function to call when a new DDP connection is established.