AEM SPA React Components in different Projects/Sites | Community
Skip to main content
July 18, 2023
Solved

AEM SPA React Components in different Projects/Sites

  • July 18, 2023
  • 1 reply
  • 843 views

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 ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ManviSharma

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.

1 reply

ManviSharma
Adobe Employee
ManviSharmaAdobe EmployeeAccepted solution
Adobe Employee
July 18, 2023

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.

February 1, 2024

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.