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 theisGuestproperty 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.
You can use @salesforce/user in a TypeScript file. This scoped module corresponds to the user.d.ts type definition in the @salesforce/lightning-types npm package.
See Also