Build a React SPA on the Enonic GraphQL API
Contents
This is a step-by-step tutorial on building a client-side React application that renders structured content from Enonic. The application fetches published content through Guillotine, Enonic’s GraphQL API, and uses the @enonic/react-components library to render rich text.
| Just want to see the result? Run the demo to try the finished application without going through the chapters. |
Intro
Enonic can be used as a headless CMS: editors manage content in Content Studio, and your application reads it through an API. In this tutorial the application is a single-page application built with Vite, which runs entirely in the browser.
When you are done, the application lists persons like this:
You will complete the following steps:
-
Set up Enonic with sample content, and try out the GraphQL API
-
Create a React app and connect it to Enonic
-
List persons fetched from the API
-
Show the details of a single person
-
Render rich text, with control over links and images
-
Render macros using your own React components
The tutorial covers delivery of published content. If you need server-side rendering or live preview in Content Studio, have a look at the Next.js tutorial instead.
Prerequisites
You should be familiar with React and TypeScript. If Enonic is new to you, complete the introduction to Enonic before starting this tutorial.
To follow this tutorial you will need:
-
Node.js 24 or newer, with npm
-
Your favorite code editor
You will install the Enonic CLI in the first chapter.
Tested versions
This version of the tutorial was produced and tested with the following stack:
| Component | Version |
|---|---|
|
Enonic XP |
8.1 |
|
Guillotine |
9 |
|
|
7 |
|
React |
19 |
|
Vite |
8 |
Using an older setup? Select the matching tutorial version from the version menu on this page.
Get started by setting up Enonic.