Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session
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

2 Replies

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.

Avatar

Level 1

Hi,

But how can we convert it as a npm package. does it differs from usual process f how we convert a create-react-app into an npm package? if so, please share the steps.