Class User<UserFunctionsFactoryType, UserCustomDataType, UserProfileDataType>

Representation of an authenticated user of an App.

Type Parameters


  • get customData(): UserCustomDataType
  • You can store arbitrary data about your application users in a MongoDB collection and configure Atlas App Services to automatically expose each user’s data in a field of their user object. For example, you might store a user’s preferred language, date of birth, or their local timezone.

    If this value has not been configured, it will be empty.

    Returns UserCustomDataType

    The custom data as an object.


  • Adds a listener that will be fired on various user related events. This includes auth token refresh, refresh token refresh, refresh custom user data, and logout.


    Returns void

  • Call a remote Atlas App Services Function by its name.


    • name: string

      Name of the App Services Function.

    • Rest ...args: unknown[]

      Arguments passed to the Function.

    Returns Promise<unknown>

    A promise that resolves to the value returned by the Function.


    Consider using functions[name]() instead of calling this method.


    // These are all equivalent:
    await user.callFunction("doThing", a1, a2, a3);
    await user.functions.doThing(a1, a2, a3);
    await user.functions["doThing"](a1, a2, a3);


    // The methods returned from the functions object are bound, which is why it's okay to store the function in a variable before calling it:
    const doThing = user.functions.doThing;
    await doThing(a1);
    await doThing(a2);
  • Link the user with an identity represented by another set of credentials.


    • credentials: Credentials

      The credentials to use when linking.

    Returns Promise<void>

    A promise that resolves once the user has been linked with the credentials.

  • Parameters

    • serviceName: string

      The name of the MongoDB service to connect to.

    Returns MongoDB

    A client enabling access to a MongoDB service.


    let blueWidgets = user.mongoClient("myService")
    .find({ color: "blue" });

Generated using TypeDoc