Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

ClientContext to ContextHub migration guide


Level 4

Hi All,

ClientContext is being deprecated for ContexHub. If you have experience of using both, please see if you can help with following information

  1. Comparison between the two - We don't see anything in official documentation.
  2. Migration/Upgrade information from ClientContext to ContextHub - Current application is using clientcontext for personalization (Campaigns, Teasers, Segments).  Is there a migration guide which can help application use ContextHub (Similar to the way upgrade for AEM versions has).

Any additional information, experiences around clientcontext, contexthub would also be helpful.

Thank you


7 Replies



Replying to First part of the question:

1. Caparison between 2:- AEM 6.1 : ClientContext Vs Context hub

Context hub is a replacement for client context it is better and more lightweight or ClientContext is basically the old version, ContextHub its replacement.

Client context had performance problems, it forces integration to wait on stores.init.js, ajax call, which slows stuff down a lot (esp site catalyst page-view calls). Context hub is a lot faster and fixes that.

Engineering team is avoiding changes to client context. Future is context hub.

In 6.1, the feature set of ClientContext was still higher than ContextHub, which itself relied on some ClientContext core functionalities to work.

With 6.2, we should have closed the gap, and we're currently working with Product Management to get the ClientContext deprecated in favor of the ContextHub.

I guess it would be a good idea to highlight some of the major architectural changes to clarify why ContextHub soon replaces ClientContextt:

ContextHub decouples the Kernel from the UI leading to a much lower footprint on publish

ContextHub Stores can deal with complex hierarchical objects while ClientContext was limited to key-value pairs

The eventing model of ContextHub is a lot more sophisticated including the fact that eventing happens as soon as stores are available and not just after „all“ stores have been loaded

Loading behavior can be controlled on a fine grained level (sequence of loading & synchronous as well as asynchronous store loading)

All in all ContextHub is capable of every aspect ClientContext could deal with and is optimized in the most significant areas of clientcontext that turned out not to work perfect due to the architecture.



Level 4

I have created the document , will upload it here for the migration guide.

Also let me know you need the package.


Level 4

Thank you kautuksahni and tc82. The package and document would be helpful.


Level 4

tc82  - Gentle reminder, if you could share the document, package you were talking about.


Level 4

ContextHub Implementation

· Table of contents

    • Introduction to ContextHub
    • Files to be changes to replace CleintContext with ContextHub


Introduction to ContextHub:

  • Name  the folder as: contexthub
  • Create a folder undern contexthub called modules
  • Create a folder undern modules called commerce
  • Create a folder undern commerce called clientlib
  • Create a file under clientlib named as .content.xml
  • Code for the .content.xml


  • Add the following line inside the css.txt
  • Create a file under clientlib named as js.txt
  • Add the following line inside the js.txt
  • Create a file under clientlib named as  renderer.commerce.css
  • Add the following line inside the renderer.commerce.css


  • Create a folder under above path named: stores
  • Create a folder under stores named: commerce
  • Create a folder under commerce named: clientlib
  • Create a file under clientlib called .content.xml
  • Add the following code in the .content.xml


  • Add the following code:
  • Create a new file under clientlib called store.commerce.js
  • Add the followig code:


  • Create a folder named customclientcontextlibs
  • Create a file .content.xml under customclientcontextlibs folder.
    Add the following code:


function callingSatellitePageBottom(){
if (window.ContextHub) {
ContextHub.eventing.on(ContextHub.Constants.EVENT_INITIALIZED + ":XXXX", function(event, data) {

  1. Including the CSS and ContextHUb:

<cq:includeClientLib css="cardinalhealth.oe.customclientcontextlibs" />

<cq:include path="contexthub" resourceType="granite/contexthub/components/contexthub"></cq:include>

  1. Get the COntextHUb Data:

//ContextHub tree details command:
var data = ContextHub.getStore('XXXX').getTree();

I have attached the zip of files modified from my local.

Note: XXXX is the store name

am not able to attache the package.