Search.../

currentUser

Gets the current user viewing the site.

Description

Gets a User object containing information about the user currently viewing the site.

Type:

UserRead Only

Was this helpful?

Get the current user's information

Copy Code
1import wixUsersBackend from 'wix-users-backend';
2
3// ...
4
5let user = wixUsersBackend.currentUser;
6
7let userId = user.id; // "r5cme-6fem-485j-djre-4844c49"
8let isLoggedIn = user.loggedIn; // true
9
10user.getEmail()
11 .then( (email) => {
12 let userEmail = email; // "user@something.com"
13 } );
14
15user.getRoles()
16 .then( (roles) => {
17 let firstRole = roles[0];
18 let roleName = firstRole.name; // "Role Name"
19 let roleDescription = firstRole.description; // "Role Description"
20 } );