Get Information About the Current User
To get information about the current user, use the @salesforce/user
scoped module.
property
—The supported properties areId
, which is the user’s ID, andisGuest
, which is a boolean value indicating whether the user is a guest user. Use theisGuest
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