Get Current User Id Information in Lightning Components

Getting a Current User Info used to be a hurdle in lightning before Winter 18.

We have to call apex method to return system.UserInfo.getUserId() now we no longer have to do this method.

In the Lightning Controller, we just need to call the $A.get(“$SObjectType.CurrentUser.Id”) to get the information

var userId = $A.get("$SObjectType.CurrentUser.Id");

This helps in reducing unnecessary calls between the server and client.