Skip to main content
Level 5
Aug 22, 2018 2:17 PM UTC
Solved

Overlay vs Extend

Is there any advantage to overlaying components than just extending them using sling:resourceSuperType?

Overlay allows you to copy over libs components to apps and changing them without affecting the original component. Doesn't extending the component also allow the same - you can just overwrite the script where changes are required? In addition, extending can make it future-proof, that is, if you happen to upgrade AEM in the future, extending components will allow you to use the latest available components in /libs.

Or is there anything that can only be achieved using overlay that I'm missing here?

Thanks for any inputs here.

Ratna_Kumar
Ratna_KumarAccepted solution
Level 10
Aug 22, 2018 6:25 PM UTC

Hi,

I basically prefer extending a component in AEM because, if you extend the component and setting the property sling:resourceSuperType to the particular path of the component and you can modify the component according to your project requirements.

Also - Once you upgrade your AEM to higher version, you can inherit the features of existing component from OOTB and you no need to manually make the changes.

'

And Overlays - Here you can copy the component from OOTB to your apps and make changes according to your project requirements. Here when you upgrade to higher version of AEM, you need to manually apply the changes(No inheritance from OOTB).

Here is the nice explanation as Scott provided: cq5 - overlay/overriding v/s extending of components in AEM - Stack Overflow

Hope this helps!!

Thanks,

Ratna Kumar.

4 replies

smacdonald2008
Level 10
Aug 22, 2018 4:00 PM UTC

That is a good question. When you want to modify a component - the typical way is to use Overlay - as described here: Overlays

Also a very good answer here too: cq5 - overlay/overriding v/s extending of components in AEM - Stack Overflow

Translate
Ratna_Kumar
Ratna_KumarAccepted solution
Level 10
Aug 22, 2018 6:25 PM UTC

Hi,

I basically prefer extending a component in AEM because, if you extend the component and setting the property sling:resourceSuperType to the particular path of the component and you can modify the component according to your project requirements.

Also - Once you upgrade your AEM to higher version, you can inherit the features of existing component from OOTB and you no need to manually make the changes.

'

And Overlays - Here you can copy the component from OOTB to your apps and make changes according to your project requirements. Here when you upgrade to higher version of AEM, you need to manually apply the changes(No inheritance from OOTB).

Here is the nice explanation as Scott provided: cq5 - overlay/overriding v/s extending of components in AEM - Stack Overflow

Hope this helps!!

Thanks,

Ratna Kumar.

Translate
Level 5
Aug 23, 2018 1:16 PM UTC

Thanks Ratna and Scott!

Translate
Level 2
Mar 12, 2025 4:22 PM UTC

Hi I guess we are doing overlay on the components that is already authored...

For example in the currently authored pages we have components with
resourceType:cq/sample-component

One way for us to override the currently authored cq/sample-components is by overlaying.

Translate