AEM Headless quick setup for AEM as a Cloud Service
The AEM Headless quick setup gets you hands-on with AEM Headless using content from the WKND Site sample project, and a sample React App (a SPA) that consumes the content over AEM Headless GraphQL APIs.
Prerequisites
The following are required to follow this quick setup:
-
AEM as a Cloud Service Sandbox environment (preferably Development)
-
Access to AEM as a Cloud Service and Cloud Manager
- AEM Administrator access to AEM as a Cloud Service
- Cloud Manager - Deployment Manager access to Cloud Manager
-
The following tools must be installed locally:
- Node.js v18
- Git
- An IDE (for example, Microsoft® Visual Studio Code)
1. Create a Cloud Manager Git repository
First, create a Cloud Manager Git repository which is used to deploy the WKND Site. The WKND Site is a sample AEM website project that contains content (Content Fragments) and a GraphQL AEM endpoint used by the quick setup’s React App.
Screencast of steps
-
Navigate to https://my.cloudmanager.adobe.com
-
Select the Cloud Manager Program that contains the AEM as a Cloud Service environment to use for this quick setup
-
Create a Git repository for the WKND Site project
- Select Repositories in the top navigation
- Select Add Repository in the top action bar
- Name the new Git repository:
aem-headless-quick-setup-wknd
- Git repository names must be unique per Adobe organization,
- Select Save, and wait for the Git repository to initialize
2. Push sample WKND Site project to Cloud Manager Git Repository
With the Cloud Manager Git repository created, clone the WKND Site project’s source code from GitHub and push it to Cloud Manager Git repository. Now Cloud Manager to access, and deploy the WKND Site project to the AEM as a Cloud Service environment.
Screencast of steps
-
From the command line, clone the sample WKND Site project’s source code from GitHub
code language-shell $ mkdir -p ~/Code $ cd ~/Code $ git clone git@github.com:adobe/aem-guides-wknd.git
-
Add the Cloud Manager Git repository as a remote
-
Select Repositories in the top navigation
-
Select Access Repo Info from the top action bar
-
Execute command found in Add a remote to your Git repository from the command-line
code language-shell $ cd aem-guides-wknd $ git remote add adobe https://git.cloudmanager.adobe.com/<YOUR ADOBE ORGANIZATION>/aem-headless-quick-setup-wknd/
-
-
Push the sample project’s source code from your local Git repository to the Cloud Manager Git repository
code language-shell $ git push adobe main:main
When prompted for credentials, provide the Username and Password from Cloud Manager’s Repository Info modal.
3. Deploy the WKND Site to AEM as a Cloud Service
With the WKND Site project pushed to the Cloud Manager Git repository, it cannot be deployed to AEM as a Cloud Service using Cloud Manager pipelines.
Keep in mind, the WKND Site project provides sample content that React app consumes over AEM Headless GraphQL APIs.
Screencast of steps
-
Attach a Non-production deployment pipeline to the new Git repository
-
Select Pipelines in the top navigation
-
Select Add Pipeline from the top action bar
-
On the Configuration tab
- Select Deployment Pipeline option
- Set the Non-Production Pipeline Name to
Dev Deployment pipeline
- Select Deployment Trigger > On Git Changes
- Select Important Metric Failures Behavior > Continue Immediately
- Select Continue
-
On the Source Code tab
- Select Full Stack Code option
- Select the AEM as a Cloud Service development environment from the Eligible Deployment Environments select box
- Select
aem-headless-quick-setup-wknd
in the Repository select box - Select
main
from the Git Branch select box - Select Save
-
-
Run the Dev Deployment Pipeline
- Select Overview in the top navigation
- Locate the newly created Dev Deployment pipeline in the Pipelines section
- Select the … to the right of the pipeline entry
- Select Run, and confirm in the modal
- Select the … to the right of the now-running pipeline
- Select View details
-
From the pipeline execution’s details, monitor progress until it successfully completed. Pipeline execution should take between 30-40 minutes.
4. Download and run WKND React app
With AEM as a Cloud Service bootstrapped with the content from the WKND Site project, download, and start the sample WKND React App that consumes the WKND Site’s content over AEM Headless GraphQL APIs.
Screencast of steps
-
From the command line, clone the React App’s source code from GitHub.
code language-shell $ cd ~/Code $ git clone git@github.com:adobe/aem-guides-wknd-graphql.git
-
Open the folder
~/Code/aem-guides-wknd-graphql/react-app
in your IDE. -
In the IDE, open the file
.env.development
. -
Point to the AEM as a Cloud Service Publish service’s host URI from the
REACT_APP_HOST_URI
property.code language-plain REACT_APP_HOST_URI=https://publish-pXXXX-eYYYY.adobeaemcloud.com ...
To find your AEM as a Cloud Service Publish service’s host URI:
- In Cloud Manager, select Environments in the top navigation
- Select Development environment
- Locate the Publish Service (AEM & Dispatcher) link Environment Segments table
- Copy the link’s address, and use it as the AEM as a Cloud Service Publish service’s URI
-
In the IDE, save the changes to
.env.development
-
From the command line, run the React App
code language-shell $ cd ~/Code/aem-guides-wknd-graphql/react-app $ npm install $ npm start
-
The React App, running locally, starts on http://localhost:3000 and displays a listing of adventures, which are sourced from AEM as a Cloud Service using AEM Headless’ GraphQL APIs.
5. Edit content in AEM
With the sample WKND React App connecting to and consuming content from the AEM Headless GraphQL APIs, author content in AEM Author service and see how the React App’s experience updates in concert.
Screencast of steps
-
Log in to AEM as a Cloud Service Author service
-
Navigate to Assets > Files > WKND Shared > English > Adventures
-
Open the Cycling Southern Utah Folder
-
Select the Cycling Southern Utah Content Fragment, and select Edit from the top action bar
-
Update some of the fields of the Content Fragment, for example:
- Title:
Cycling Utah's National Parks
- Trip Length:
6 Days
- Difficulty:
Intermediate
- Price:
3500
- Primary Image:
/content/dam/wknd-shared/en/activities/cycling/mountain-biking.jpg
- Title:
-
Select Save in the top action bar
-
Select Quick Publish from the top action bar’s …
-
Refresh the React App running on http://localhost:3000.
-
In the React App, select the now updated Cycling adventure, and verify the content changes made to the Content Fragment.
-
Using the same approach, in AEM Author service:
- Unpublish an existing Adventure Content Fragment, and verify it is removed from the React App experience
- Create and publish a new Adventure Content Fragment, and verify it appears in the React App experience
note tip TIP If you are unfamiliar with creating and publishing new, or unpublishing existing Content Fragments, watch the screencast above.
Congratulations!
Congratulations! You’ve successfully used AEM Headless to power a React App!
To understand in detail how the React App consumes content from AEM as a Cloud Service, check out the AEM Headless tutorial. The tutorial explores how Content Fragments in AEM as created, and how this React App consumes their content as JSON.