The internet wasn't too kind to me this time. This is all I could find. So:

I know it is possible to get the runtime generated unique Id of the corresponding component like so:

var globalId = component.getGlobalId();

But, is it possible to get the name of the component programmatically in JS? That is, if my component is called 'ProjectView.cmp', the method should return 'ProjectView'.


you can simply use getName() method.

it returns the component's code-compatible camelCase name, e.g. 'cProjectView'

so if you want to get name without your custom namespace:

var cmpName = component.getName(); 
cmpName = cmpName.substr(1);

if you want to get name with namespace:

var cmpName = component.getType();
  • 1
    Thanks for the aura framework documentation. Didn't even know something like that existed! – Lightning Evangelist Mar 21 '18 at 23:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.