get User-Id In Lightning Web Component Salesforce

by Rijwan Mohmmed
0 comment

We can get the current user-Id in Lightning Web Component in Salesforce, for this we need to import the

import UserId from '@salesforce/user/Id';

Lets learn with a simple example :

mycomp.html :

        <h2> User Id : {currentUserId} </h2>

mycomp.Js :

import { LightningElement } from 'lwc';
import UserId from '@salesforce/user/Id';
export default class MyComp extends LightningElement {
    currentUserId = UserId;

You may also like

Leave a Comment