Same as Aura components, Lightning web components have a lifecycle managed by the framework. The framework is in charge of:
- In the creation phase, create the components, insert them into the DOM, and finally render them.
- In the destroy phase, remove them from the DOM.
You can check nice diagrams for both phases here.
During these phases, there are hooks that you can use, either to inject some extra code or to directly override the behaviour: