Skip to content

Get User

This function retrieves and returns the current user information.

Usage

Node.js

const user = await provider.auth.getUser('<token>');

Next.js

const user = await provider.auth.getUser();

Express.js Requires useProductFlame middleware.

app.get('/profile', async (req, res) => {
const user = await req.auth.getUser();
// ...
});

Arguments

NameTypeDescription
tokenOrReqstring | IncomingMessageRequired (Node.js only). The session token string, or the HTTP request object (to extract the token automatically).

Response

Type: Promise<User>

Returns the user object.

PropertyTypeDescription
idstringThe unique user ID.
emailstringThe user’s email address.
provider'local' | 'google' | 'github'The authentication provider used to create the account.
createdstringISO date string of account creation.
payment.usedTrialbooleanTrue if the user has ever used or is using a trial.
payment.subscriptionsSubscription[]List of active subscriptions.

Errors

  • AUTHENTICATION_REQUIRED: User not authenticated.
  • UNKNOWN_ERROR: An unknown error has occured.