Expand my Community achievements bar.

SOLVED

How to Share React components across multple applications with AEM SPA

Avatar

Level 2

Hi All,

 

I have 3 AEM SPA react applications within the same AEM repository. All these 3 applicaitions using AEM SPA React framework. Lets say AEM SPA react app a1, a2, a3. these a1, a2,a3 apps generate with maven acrhetype AEM SPA 4.0. As you all know that when we want to create any new component we need to map the specific component to AEM react app page component to display on the page.

My requirement is to re-use the components a1 app in a2 and a3. without mapping these components I am not able to re-use them in the AEM application. 

 

are there any other ways to resolve this issue?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@arunaaems506124 

In AEM SPA architecture every react component to every AEM component. So it's one to one mapping.
In your case as you have a new project under /apps then you need to create a new one to one mapped component once again.

One way is adding the component from first app to second app by updating the page policies (This should solve your issue of reusing the components)

Thanks,
Nikhil 

4 Replies

Avatar

Correct answer by
Community Advisor

@arunaaems506124 

In AEM SPA architecture every react component to every AEM component. So it's one to one mapping.
In your case as you have a new project under /apps then you need to create a new one to one mapped component once again.

One way is adding the component from first app to second app by updating the page policies (This should solve your issue of reusing the components)

Thanks,
Nikhil 

Avatar

Level 2
We are also facing similar issue, when we updated page policy in templated , we can see that component available on page but when we add it on page , nothing happens

Avatar

Level 1

Did this accepted answer work for anybody? I deployed 2 aem spas, lets call it spa1 & spa2, to my local author. I updated the page policies of spa2 to include components from spa1. In a spa2 page, I am able to see and add spa1 components, but then nothing is shown on the page. 

Avatar

Level 2
Hi Arun, Have you got solution to this issue ?
page footer
Change Username