Accounts let users log on a meteor app. This example shows how to let users log with passwords.

The Accounts example code is on github, to get it run:

git clone

  1. Packages
  2. Templates
  3. Javascript
  4. Configuration

1. Packages

Add these packages to the meteor app:

meteor add accounts-ui
meteor add accounts-password

For the bootstrap version of accounts, add these packages:

meteor add ian:accounts-ui-bootstrap-3
meteor add accounts-password

2. Templates

The login buttons can added anywhere in the templates:

Use ‘#if currentUser’ and ‘#unless currentUser’ to detect if the user logged on.

{{#if currentUser}}

{{#unless currentUser}}
Please log.

3. Javascript

The user is identified by a userid: Meteor.userId()

Users can be logged on several devices, there is a function to log off all other clients: Meteor.logoutOtherClients()

User data is updated with Meteor.user.update(), for example:

                    {$set: {'': 'Jane Schmidt'}}

Users are deleted with the function remove:

// remove user

A function can be called when new user are created:

Accounts.onCreateUser(function(options, user) {
  user.profile = {name:'Joe Schmoe', avatar:'Missing'};
  return user;

To get the number of accounts use:


To create new accounts from the code, use Accounts.createUser():

var userid = Accounts.createUser({
  email:    '',
  password: 'demo',
  username: 'demo',
  profile:  {name: 'demo'}

Meteor.users.update({_id:userid}, {$set: {'email.0.verified':true}});

4. Configuration

Accounts.config holds the global accounts options. We can enable/disable account creation, force email verification and number of days until the user must log on again. Accounts.ui.config holds the options for the ui. With passwordSignupFields, we choose which to display in the accounts ui: only username or username and email.

  forbidClientAccountCreation : false