Skip to main content


Github | npm


Add @accounts/client to your app with yarn or npm:

# With yarn
yarn add @accounts/client

# Or if you use npm
npm install @accounts/client --save


import { AccountsClient } from '@accounts/client';

const accountsClient = new AccountsClient({}, myTransport);

Use cases

The @accounts/client module exposes a set of methods that can be used in any JavaScript framework.


Login the user with a specific service.

await accountsClient.loginWithService('serviceName', credentials);

// For example with the password service
await accountsClient.loginWithService('password', {
user: {
password: values.password,


Logout the user.

// For example with the password service
await accountsClient.logout();

Retrieve the current authenticated user

Will return the current logged in user informations. Must be logged in.

// For example with the password service
await accountsClient.getUser();

Impersonating another user

If you need to you can allow some users via server authorization to impersonate the other users accounts, e.g.: Only admin users can impersonate to other users. Your current session will be replaced by another impersonated session. Must be logged in.

await accountsClient.impersonate({ userId: 'userId' });

// When you are done, you must stop the impersonation process
// Your other session will be restored
await accountsClient.stopImpersonation();