I have gone through definition of LightningElement but unable to understand it clearly.

Definition LightningElement is a custom wrapper of the standard HTML element.It extends element to create a JavaScript class for a Lightning web component.

1 Answer 1


Additionally to what you found online:

LightningElement is the base class for Lightning web components, which allows us to use connectedCallback().


In other words it's a JavaScript class that allows you to leverage on it when you extend it. Once you extend it the methods from that class become immediately available to you. Such as connectedCallback(), renderedCallback(), disconnectedCallback(), errorCallback(error, stack), etc.

Additionally it's necessary to extend this class to supply a JS controller for your lightning web component.

If I erase the extends part from export default class App extends LightningElement { I get the following error:

TypeError: class App {} is not a valid component, or does not extends LightningElement from "lwc". You probably forgot to add the extend clause on the class declaration.

If we look at the stacktrace(I'm doing this in LWC Playground) we can see that this error comes from a file called engine.js. That file has over 6000 rows so it is beyond my ability to comprehend it but maybe somebody else who is more familiar can add up to my answer.

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.