Skip to Content
Headless PaaS CMS 13 Masterclass

Part 2: Architecture overview

How Optimizely CMS 13, Optimizely Graph and a Next.js front end fit together, what headless gains and loses on CMS 13, and the stack this masterclass uses.

In Part 1, I argued that headless is the natural default on CMS 13. This part makes that concrete. It shows how the CMS, Optimizely Graph and the front end fit together, what you gain and what you give up by going headless on CMS 13 specifically, and which stack the rest of the masterclass builds on.

There's no code in this part. The hands-on work starts in Part 3, and every decision below is one you'll see applied there and in the parts after it.

Before you start

You only need to have read Part 1. There's nothing to install yet.

If you're weighing headless in general, Going Headless: Making the Right Architectural Choices covers when it fits and when it doesn't, and the main choices behind a headless Optimizely site: PaaS or SaaS, DXP or self-hosted, Next.js or another framework, one repository or two. I won't repeat that here. This part is about what's specific to CMS 13 and to this masterclass.

How the pieces fit together

A headless CMS 13 solution has three main parts:

  • Optimizely CMS 13: the .NET application where editors create content and where developers define content types. In this masterclass, it's hosted on DXP.
  • Optimizely Graph: a GraphQL service, hosted by Optimizely, that keeps a synced copy of your content and answers queries about it. You don't host or deploy it yourself.
  • The front end: a Next.js application, hosted on Vercel, that queries Graph and turns the results into pages.
CMS 13 headless architecture Optimizely CMS 13 syncs content to Optimizely Graph, and the Next.js front end on Vercel reads it from Graph with the public Single Key, pulls content type definitions from the CMS at development time, and is embedded in the CMS for live preview. SYNC SINGLE KEY CONFIG PULL LIVE PREVIEW CMS Optimizely CMS 13 PaaS · DXP API Optimizely Graph hosted GraphQL APP Next.js front end Vercel LEGEND Content API Application Content sync Front-end query Dev and editor time
The CMS syncs content to Graph and the front end reads it from there. The dashed connections only matter while you develop and while editors edit.

Each arrow is a connection you'll set up during the masterclass.

Sync, from the CMS to Graph. When editors save or publish content, the CMS sends it to Graph. You don't write any sync code: Part 3 adds the Graph integration to the CMS project, and from then on it runs by itself. Graph receives drafts as well as published content, which is what makes live preview possible later.

Single Key, from Graph to the front end. The front end fetches content from Graph with the Single Key: a public, read-only key that only returns published content. Because it can't read drafts or change anything, it's safe to use in places visitors can see.

This means a visitor's request never reaches the CMS for content. The front end asks Graph, and the CMS can be busy or in the middle of a deployment without affecting it. There's one exception: images. Graph returns their URLs, but the files themselves are still served by the CMS. Part 5 works with that as it is, and Part 11 looks at delivering them through the DXP CDN.

Config pull, from the CMS to the front end, at development time. Content types, such as a home page or a hero block, are defined in C# in the CMS project. The front end needs matching TypeScript types to render them. Optimizely's command-line tool reads the content types from the CMS and generates those types, with a command called config pull. You run it when a content type changes, not on every request, which is why the arrow is dashed. Part 5 sets it up.

Live preview, from the front end into the CMS, at editing time. When an editor opens a page in Visual Builder, the CMS shows the real front end inside its editing interface, in an iframe. Editors see their changes rendered by the same code your visitors get, not by a CMS approximation of it. Part 6 wires this up. It's also why, from Part 3 on, the front end runs over HTTPS even on your machine: the CMS runs over HTTPS and embeds the front end, and keeping both on HTTPS locally matches how they run once deployed.

Graph can also index content from sources outside the CMS and serve it through the same API. This masterclass doesn't use that, so it's not in the diagram.

What headless gains and loses on CMS 13

The general trade-offs of headless, such as hosting two applications instead of one, are covered in Going Headless: Making the Right Architectural Choices. Two things are specific to CMS 13, and they're worth knowing before you start: one works in your favour, one doesn't.

Gain: content variations

Content variations are CMS 13's built-in way to keep several published versions of one page or content item. A variation isn't a copy: it belongs to the same content item, with its own name and its own publishing history. Editors create them in the CMS, for example a winter campaign version of the home page, or two versions of a landing page for an A/B test. Optimizely's content variations documentation covers the editor side.

Variations fit headless well, because Graph indexes them like any other content. A Graph query returns only the original version by default, and it can ask for a specific variation by name. So the decision about which version a visitor sees moves to the front end, which is where a headless solution makes decisions like that anyway. Part 7 builds a simple version of it: a query string parameter picks which variation of the home page to render.

Loss: audiences

Audiences, called visitor groups before CMS 13, are the CMS's built-in personalization rules, such as "visitors from Poland" or "visitors who came from a campaign link". Editors use them to show different content to different visitors, for example a different block in a content area.

They don't work in a headless setup. The CMS evaluates an audience while it renders a page, using what it knows about the visitor's request. In a headless solution, the CMS doesn't render pages, and Graph never sees the visitor, so there's nothing to evaluate the rule against. Optimizely's audiences documentation says it directly: "Audiences do not work on headless sites, where the frontend is an independent application that consumes content through APIs."

It can be worse than "doesn't apply". In Piotr Nowak's tests on CMS 13.1.0, a block personalized with an audience disappeared from Graph, and so did its place in the page's content area, without any error. I haven't re-tested that on the version this masterclass uses, but the lesson stands: keep audience personalization out of content that a headless front end reads.

What to do instead? Personalization becomes a front-end decision. The pattern I'd reach for combines the gain with the loss: keep each personalized version as a content variation, and let the front end decide which one a visitor gets, either with its own logic or with a dedicated tool such as Optimizely Feature Experimentation. Minesh Shah describes this approach in Personalisation in CMS 13 when you go headless. Optimizely's experimentation and personalization products are outside the scope of this masterclass, so in Part 7 a query string parameter stands in for whatever makes that decision in a real project.

The stack

These are the choices the rest of the masterclass is built on, each with the short version of why. Going Headless goes deeper into the alternatives.

CMS: Optimizely CMS 13 on DXP

The CMS is PaaS CMS 13, version 13.6.0 at the time of writing, hosted on DXP, Optimizely's cloud hosting for PaaS CMS. DXP takes care of the servers and the CDN in front of your site, so there's less infrastructure for you to run. As Part 1 explains, you can follow along with the CMS hosted elsewhere and adapt the DXP-specific steps.

Two Optimizely services are connected to it from the start, in Part 3:

  • Opti ID, Optimizely's single sign-on, for editors and administrators signing in to the CMS.
  • Optimizely Graph, for content delivery, as described above.

Front end: Next.js on Vercel, with pnpm

The front end is Next.js with the App Router, Next.js's current routing model. Optimizely's JavaScript SDK has dedicated Next.js helpers, including one for live preview, and most of its starter templates are Next.js apps, so it's the best-supported path for a headless Optimizely front end today.

It's hosted on Vercel, the company behind Next.js. Vercel deploys a Next.js app straight from a Git repository with almost no configuration. Next.js isn't tied to Vercel, though: it runs on any Node.js host, so choosing another one changes the deployment part, not the architecture.

The package manager is pnpm. It installs quickly, keeps one copy of each package on disk, and is strict about dependencies, so a package can't quietly rely on something it never declared. npm works too, but every command in this masterclass uses pnpm.

SDK: the official Optimizely JavaScript SDK

The front end talks to Graph through Optimizely's official SDK: @optimizely/cms-sdk, with its command-line tool @optimizely/cms-cli, both version 3.1.0. Part 3 adds them to a plain Next.js project with Optimizely's cms-create-app tool.

I chose it for two reasons. It has ready-made React components for rendering Visual Builder layouts and for live preview, and it doesn't need a code generation step to turn GraphQL queries into TypeScript types.

The main alternative is to write the GraphQL queries yourself and generate types from them, for example with Remko Jantzen's community packages, which Optimizely's own SaaS CMS demo sites use. That gives you full control over every query, at the cost of a code generation pipeline to maintain. Part 5 compares the two in detail.

The trade-off: the SDK is the youngest part of this stack. Version 3.1.0 was the first to name PaaS CMS 13 as a supported target, and major versions have brought breaking changes. Expect this area to keep moving, and pin your versions.

Content types live in the CMS

Content types are defined in C#, in the CMS project, and the front end pulls them with config pull. On PaaS, the CMS project is your own .NET application. It's where integrations, scheduled jobs and other server-side logic live, so the content model lives there too, next to the code that uses it.

This is worth knowing if you compare this masterclass with Optimizely's Next.js starter templates, which do the opposite: they define content types in TypeScript and push them to the CMS with config push. That's the natural model for SaaS CMS, where there's no .NET project of your own. The two approaches keep the content model in different places, so the code looks different.

One repository, two folders

Both projects live in one Git repository, as plain folders:

masterclass-cms/
  HeadlessMasterclass.slnx
  HeadlessMasterclass.Web/
masterclass-web/

masterclass-cms/ holds the CMS: a .NET solution, HeadlessMasterclass.slnx, with one project, HeadlessMasterclass.Web. masterclass-web/ holds the Next.js front end.

One repository means a content type change and the front-end code that uses it can go into the same commit and the same pull request. There's no monorepo tooling such as Turborepo or Nx, because the two projects are in different languages, share no code and build separately, so there's nothing for such a tool to coordinate. Each host builds only its own folder: Vercel the front end, DXP the CMS. Part 4 sets that up.

Trade-offs to keep in mind

  • Two applications. You host, deploy and monitor the CMS and the front end separately, in two languages. AI coding assistants make that cheaper than it used to be, but it's still two things to keep running.
  • A young SDK. If something in a later part doesn't match what you see, check your versions against the ones in Part 1 first.
  • Personalization is your job. Audiences don't carry over to headless. Content variations do, but the logic that picks a variation for a visitor is something you build or buy.

What's next

In Part 3, Creating an empty CMS 13 project, you'll set up both projects: an empty CMS 13 site connected to Opti ID and Optimizely Graph, and a Next.js front end with the Optimizely SDK, both running on your machine.