Hi,
I want to do POC on AEM with Microfrontend integration. I have gone through the below links but not useful much. Please help me with the steps how to proceed further.
https://medium.com/@satyambansal001/aem-react-run-multiple-react-apps-on-single-aem-page-without-eje...
https://medium.com/@gaurav.poojari/aem-micro-frontend-integration-aee64e923b00
Thanks & Regards,
Kalyan
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
I have read both online resources that you also followed I believe they are pretty good and they give a step-by-step approach on how to setup your project to leverage micro-frontent architecture pattern.
What exactly are your bottlenecks when you try into practice ? Maybe you can share more about what do you want to demonstrate with your PoC ? Also what version of AEM are you using ? And so on...
Hi @SorinDiaconescu ,
Thank you for inputs.
There is no specific use case as part of POC. First Iam trying to understand how to Integrate AEM with microfrontend as we might have similar to sample project wknd-app/we-retail. By using that want to try in my local and after that we will do as part of the project POC.
Iam using AEM 6.5
Please let me know if you have more documentation with steps using oob like wknd-app and then will work further if any customisation need to do.
Thanks & Regards,
Kalyan
In that case I believe those two online resources gives you enough knowledge to get an idea about how things work and how to make an initial project setup.
As I see it, long story short, all comes down to put your frontend solution into your AEM project and have it built, packaged and delivered along with the AEM artifacts. Typically you will have the React components or other library solution into ui.frontent (i have seen it in ui.apps as well sometimes).
Then you need a way to package them as AEM clientlibs and shifted with the AEM artifacts when you build and deploy your AEM project. I guess that is the inflection point that is not thoroughly explained. They all use https://github.com/eirslett/frontend-maven-plugin plugin to tap into the Maven build cycle and build your frontend in the process.
So basically your pom file can contain something like this:
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>npm build production</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>run build:microfrontent</arguments>
</configuration>
</execution>
</executions>
</plugin>
During AEM maven build, it will also invoke the script run build:microfrontent, which will have to be defined in the package.json file. This script can either be a webpack command or react-app-rewired command as decribed in those two articles, or it can directly be a custom JS script that you need write that will programmatically have to transform your React, or whatever stuff you have, into AEM clientlibs.
1. Using webpack command
The webpack.dev.js is mentioned in the article you shared. And I image it will be used like this:
"scripts": {
"build:microfrontent": "rm -rf ../ui.apps/src/main/content/jcr_root/apps/project/clientlibs/* && webpack -d --env dev --config ./webpack.dev.js && clientlib --verbose",
},
For this, your transformation logic will go into webpack.dev.js:
Content of this file I cannot share unfortunately, as it is confidential, but maybe you can get some inspiration from here:
https://www.freecodecamp.org/news/an-intro-to-webpack-what-it-is-and-how-to-use-it-8304ecdc3c60/
2. Using react-app-rewired
The article you shared already covers everything I believe
3. Using custom JS
The command will look something like:
"scripts": {
"build:microfrontent": "node ./package-microfrontend.js"
},
Again the content of package-microfrontend.js file I cannot share due to confidentiality aspect, but I can tell it should be developed by someone who know how to work with files in JS, with read & write operations.
Hi @Tethich,
Thank you for your inputs. I will try and let you know if I require any inputs further later after sometime.
Thanks & Regards,
Kalyan
Views
Replies
Total Likes
Hi @Tethich,
I have one doubt how the authored data will be consumed by micro frontend and render on the page.
For example: If we have Image component/Text component authored in AEM. How we can get the data from AEM to UI for rendering
Thanks & Regards,
Kalyan
As it has been described in those articles also, you basically need to expose your AEM data to the Microfrontend components. It depends on the architecture (headless vs headfull vs hybrid) of course. You can understand more from this article: https://medium.com/@prajwaljainkmt/aem-architecture-headful-vs-headless-vs-hybrid-cb7a757b398f
1. In a non-headless architecture, you can have a Sling model that reads your Image component/Text component data and makes it available for the component's HTL to use. In the HTL then that data is being dropped typically into a specific data- attribute (as your article is mentioning) from where the frontend components will know how to read and use to render the UI.
This works for React and Angular as I have seen it.
If you have a proprietary in-house JS based design system, other then React or Angular or whatever, you may leverage a library called AlpineJs which in such cases I have seen it can be really powerful.
2. In a headless solution thought, you will need to expose you AEM component's data via REST API, which you might need to develop. For CFs you can leverage AEM's GraphQL. For Assets you can leverage ootb Asset API de. For the rest you might need to wrote your own Sling Servlets.
Hi @Tethich ,
Thank you for clarification and Iam able to understand as per the blogs. But my doubt is on the page we can author many components. How these components data will get rendered on the page.
In the servlet/model do we need to write logic to get all the components data and expose as a json or do we have any mapping to each component similar to SPA
Thanks & Regards,
Kalyan
Views
Replies
Total Likes
I would say you would need to write logic to expose json containing component data.
So the most basic example for a core component, for example Carousel one, would look something like:
<div data-sly-use.carousel="com.adobe.cq.wcm.core.components.models.Carousel"
data-something="${carousel.data.json}" />
For a custom component it will be similar, but using your Sling model.
Hi @Tethich ,
I did not understand, for headless solution how we need to expose the data and component mapping in ReactJS/AngularJS
Thanks & Regards,
Kalyan
Views
Replies
Total Likes
I mentioned it in my comment before my last one, at point 2. If you want to dig more , you can start with this Adobe documentation:
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/headless/introdu.... It explains the authoring journey in the headless context.
I have not had a chance to try this yet. Please check this article - https://jcdubs.medium.com/serverless-vue-micro-frontend-b4eda030137d if it helps to proceed.
Thanks
Narendra
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies