Ă۶ąĘÓƵ

Overview

[For publishing from AEM Sites using Edge Delivery Services, click here.]{class="badge positive" title="Publish from AEM to Edge Delivery Services"}

Welcome to the multi-part tutorial for developers looking to augment an existing React-based (or Next.js) Remote SPAs with editable AEM content using AEM SPA Editor.

This tutorial builds upon the WKND GraphQL App, a React app that consumes AEM Content Fragment content over AEM’s GraphQL APIs, however does not provide any in-context authoring of SPA content.

video poster

Transcript
Let’s take a look at how Ă۶ąĘÓƵ Experience Manager lets you augment a remote spa to include developer specified areas or zones that are authorable by users in AEM using Spa Editor. Before we get started, let’s quickly take a look at the spa we’ll be enhancing. We’ll be using a spa that promotes weekend adventures. While the spa does consume adventure data from AEM over AEM’s GraphQL APIs, there’s nothing inherent that makes this an AEM spa. For the sake of this exercise, we can pretend that the spa pulls our adventure data from any GraphQL endpoint. The spa’s home view displays a list of adventures and clicking into them loads the adventure’s details via a dynamic route. So clicking on Bali Surf Camp pulls up the adventure details for that specific adventure. Likewise, clicking into other adventures pulls up their details. As you learn about integrating AEM Spa Editor into the spa, we’ll be using the term remote spa a lot. This is simply meant to be a way to make spa a more accessible and accessible experience. The developer in the spa is intended to run anywhere and does not need to be hosted by AEM. Rather, it’s hosted remotely on the platform of your choosing, but integrates with AEM to support content authoring and consumption. So the primary focus will be to take a look at how we can make developer defined areas in the spa editable by authors in AEM. We’ll take a look at how to replace required hardcoded text in the spa with fixed editable components, meaning the developer adds a specific editable spa component to the view and authors can then edit its content but cannot remove or move it. Next, we’ll look at how developers can add editable container components to the home view. Container components placed in the spa by developers provide areas that authors in AEM using Spa Editor can drag and drop allowed editable components into. Authors can then edit these components, either creating new or reusing existing content in AEM. Keep in mind, only components that have counterparts as AEM enabled spa components will work here, and we’ll explore the details of what these look like as well. We’ll also briefly explore how AEM’s responsive grid can be used in these containers, allowing authors to resize and arrange components. Lastly, we’ll look at how these concepts can be applied to dynamic, or parameterized, routes in the spa. For this, we’ll look at how to add editable components to the adventure detailed routes, which are defined in the spa with a prefix of adventure, and parameterized with the adventure’s ID, which in our case is the adventure’s content fragment path in AEM. We’ll learn what’s required to create dynamic mappings between editable components and these routes. Okay, I hope this gives you a taste of what you’ll learn, and I hope you have fun integrating a remote spa with AEM Spa Editor.

About the tutorial

The tutorial intended to illustrate how a Remote SPA, or a SPA running outside the context of AEM, can be updated to consume and deliver content authored in AEM.

Most activities in the tutorial focus on JavaScript development, however critical aspects are covered that revolve around AEM. These aspects include defining where the content is authored and stored in AEM and mapping SPA routes to AEM Pages.

The tutorial is designed to work with AEM as a Cloud Service and is composed of two projects:

  1. The AEM Project contains configuration and content that must be deployed to AEM.
  2. WKND App project is the SPA to be integrated with AEM’s SPA Editor

Latest code

  • The starting point of this tutorial’s code can be found on in the remote-spa-tutorial folder.

Prerequisites

This tutorial requires the following:

This tutorial assumes:

  • as the IDE
  • A working directory of ~/Code/aem-guides-wknd-graphql/remote-spa-tutorial
  • Running the AEM SDK as an Author service on http://localhost:4502
  • Running the AEM SDK with the local admin account with password admin
  • Running the SPA on http://localhost:3000
NOTE
Need help with setting up your local development environment? Check out the following guide to setting up a local development environment using the AEM as a Cloud Service SDK.

1. Configure AEM for SPA Editor

AEM configurations are required to integrate the SPA with AEM SPA Editor. These configurations are managed and deployed via an AEM Project. In this chapter, learn about what configurations are necessary and how to define them.

2. Bootstrap the SPA

For AEM SPA Editor to integrate a SPA into it’s authoring context, a few additions must be made to the SPA.

3. Editable fixed components

First, explore adding an editable “fixed component” to the SPA. This illustrates how a developer can place a specific editable component, in the SPA. While the author can change the component’s content, they cannot remove the component or change its placement, positioning, or size.

4. Editable container components

Next, explore adding an editable “container component” to the SPA. This illustrates how a developer can place a container component in the SPA. Container components allow authors to place allowed component in it, and adjust the layout of the components.

5. Dynamic routes and editable components

Lastly, use the concepts explained in previous chapters to dynamic routes; routes that display different content based on the route’s parameter. This illustrates how AEM SPA Editor can be used to author content on routes that are programmatically driven and derived.

Additional resources

recommendation-more-help
e25b6834-e87f-4ff3-ba56-4cd16cdfdec4