Expand my Community achievements bar.

SOLVED

AEM SPA React Components in different Projects/Sites

Avatar

Level 2

We have made react components in an AEM React spa project. Is there any way that we can use the same components in other projects/sites like we do for normal HTL components?

We tried using an experience fragment but that too didn't work. 

Any suggestions on how we can achieve this ?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi,

 

To reuse React components in other AEM projects/sites, you can create a shared npm package containing the React components. This package can be installed as a dependency in the AEM projects, allowing you to import and use the components in your AEM scripts or templates. This approach promotes code reusability and simplifies maintenance across multiple projects.

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi,

 

To reuse React components in other AEM projects/sites, you can create a shared npm package containing the React components. This package can be installed as a dependency in the AEM projects, allowing you to import and use the components in your AEM scripts or templates. This approach promotes code reusability and simplifies maintenance across multiple projects.