Get Information About the Current User

To get information about the current user, use the @salesforce/user scoped module.

  • property—The supported properties are Id, which is the user’s ID, and isGuest, which is a boolean value indicating whether the user is a guest user. Use the isGuest property to check whether or not the user is authenticated in the Experience Builder site.

This sample code imports the current user ID and assigns it to the userId property to provide access in the HTML template.

To reference a user ID in a template, use {property} syntax, which is the same syntax you use to reference any JavaScript property.

This code sample is the miscGetUserId component in the lwc-recipes repo.

See Also