Check User Permissions for Current User in LWC

by Rijwan Mohmmed

Hello friends, today we will discuss Check User Permissions for Current User in LWC. User-specific actions, visibility, or data access often depend on their permissions. Checking these permissions dynamically enhances security and user experience. Now we can directly check these permissions in LWC, no need to call the Apex server call.

Also, check this: Show Toast Message in Lightning Flows Salesforce

Key Highlights :

  1. Security: Ensure users only access what they’re authorized to, safeguarding sensitive data and actions.
  2. User-Centric: Provide a tailored experience, showing or hiding functionality based on user roles and permissions.
  3. Efficiency: Streamline processes by dynamically enabling or disabling features as needed.
  4. We can check custom permission and standard permission for the current user.
  5. Can Modify the component’s behavior based on the current user’s permission
  6. import hasPermission from ‘@salesforce/userPermission/PermissionName’;

Code :

Using the @salesforce/userPermission and @salesforce/customPermission scoped modules, you can check whether a user has permissions. A specific action can be taken by the component if the user has permission.

//check standard permission
import hasPermission from '@salesforce/userPermission/PermissionName';
//to check custom permission
import hasCustomPermission from '@salesforce/customPermission/Custom_Permission_Api_Name';


    <setup-button disabled={isSetupEnabled} onclick={openSetup}></setup-button>

  <template lwc:if={isReportVisible}>


import { LightningElement } from 'lwc';
import hasViewSetup from '@salesforce/userPermission/ViewSetup';
import hasViewReport from "@salesforce/customPermission/ViewReport";

export default class App extends LightingElement {
    get isSetupEnabled() {
        return hasViewSetup;

    get isReportVisible() {
       return hasViewReport;

    openSetup(e) {



<?xml version="1.0"?>
<LightningComponentBundle xmlns="">

Output :

Reference :

  1. Check Permissions in LWC
What’s your Reaction?

You may also like

Leave a Comment