Blogs
J. Todd Bennett
Vice President of Marketing

dotCMS: The Headless CMS for React

Dec 28, 2020
By: J. Todd Bennett

React was first developed in 2011 by Facebook, but it has come a long way since then. With almost ten years of changes and updates under its belt, the JavaScript framework has earned its spot as the most popular frontend framework according to npm Trends

But you shouldn't choose it only because of its popularity. React is also packed with features that simplify and improve development on JavaScript. 

Also, React can be integrated with a headless CMS like dotCMS to build and deploy robust digital experiences of all kinds. In this article, we give you a rundown of React and how it interacts with a headless CMS like dotCMS to create static sites and single-page applications.

Why React?

First of all, React is open source, which means that its code is available for everyone to see and tweak. React is often used to handle the presentation layer of web and mobile applications. The framework also enables reusability for UI components, allowing the developers to create large web applications with less effort, while also giving a seamless experience for visitors and users. 

These are some of the benefits of React:

  • It's just JavaScript and APIs, which means that it can be learned quickly
  • A huge user community and thousands of tools out there to get started
  • The virtual DOM improves speed and performance
  • Extensive code reusability 
  • Easy to test and reiterate 

Headless CMSs and React

CMSs are composed of the backend, the part responsible for handling content, and the frontend, or the head, which is the part that displays the content to viewers. Headless CMSs chop off the head, enabling developers to plug into any frontend they create, using the JavaScript framework that suits their needs. 

Also, with the rising popularity of Jamstack as a new development architecture, JavaScript frameworks like React are being used to build robust, eye-catching UIs that can be connected to the backend via APIs. 

With a hybrid headless CMS like dotCMS, frontend developers receive raw content that they can turn into something special using a JavaScript framework like React. The headless approach enables developers to concentrate on building the website's aesthetic, UX, and UI, simplifying the process and separating the concerns. 

Advantages of Headless CMSs

The main advantages of a headless CMS are related to its flexibility and the possibilities it gives developers. Let's take a look at some of the main benefits of the headless approach.

Front-End Agnostic

Headless CMSs are API-driven, which means that they allow developers to deliver content to every frontend framework they're using. Frameworks like React can consume APIs to call on data and connect the dots without the constraints of a monolithic system.

Omnichannel Delivery

One of the main gains that come with headless CMSs is that they give content creators and marketers the freedom to deliver content to a plethora of devices. Since a headless CMS doesn't dictate how your content should look, you can plug React in and deliver the same content to a website or a digital kiosk, maintaining a consistent message regardless of the channel. 

Interoperability and Extensibility

Interoperability is the ability software has to communicate and share content with other tools. Headless CMSs seamlessly connect with CRMs, intranets, portals, and customer service tools. By the same token, extensibility refers to the capacity a CMS has to grow by connecting to other data sources. 

No Vendor Lock

A headless CMS prevents the dreaded vendor lock-in because developers can build the frontend using React and integrate it with other solutions to build a best-of-breed solution that combines the best products available. 

Digital Experiences You Can Build With dotCMS and React 

One of the best things about building digital experiences with dotCMS and React is that you can bring your own custom React components into dotCMS' open source environment and shape your development process the way you want. dotCMS' headless architecture leverages APIs to read query documents using GraphQL and Rest. 

Here are some of the digital experiences you can build with dotCMS and React. 

Static Sites

Although there are hundreds of Static Site Generators, some of the most widely used ones are React-based. Many Jamstack sites leverage static site generators like Gatsby that fetch content stored in a headless CMS using APIs. Gatsby's rich plugin ecosystem lets you build sites with the data you want, allowing you to bring the data into your page using GraphQL.

Read More: Building a website with Gatsby and dotCMS: How to use a static-site generator

Single Page Applications

A single page application holds markup or HTML text and uses APIs to make calls to a server to fetch raw data. When it arrives, it gets sent to React to create the UI. dotCMS provides Layout as a Service and adds templating, personalization, rule-based content delivery, and server-side contextual rendering via React. 

Read More: Building Single Page Apps With a Hybrid Headless CMS

Mobile Applications

The main advantage of dotCMS is that its headless architecture enables content delivery to different devices from a single backend. With React, you can build the UI and use dotCMS to build the logic behind your app and send the data to React.

Read More: Today's Customers are Mobile-First, Your Strategy Should Be Too

Deploy a Single Page App Using React and dotCMS

dotCMS gives users control over the content by separating it from the presentation layer. This enables content, marketing, and development teams to work together, and each focus on improving their side of the product. 

A hybrid headless CMS like dotCMS enables the creation of Single Page Applications to deliver a much more dynamic, seamless user experience that's similar to a mobile experience, which has been proven to increase conversions and delight visitors.  

Also, thanks to Facebook's create-react-app CLI tool, creating a React app has become easier than ever. 

To build an SPA with dotCMS, you only need three things: Node.js, npm, and some basic knowledge of how React works. But in our tutorial, we'll walk you through the whole experience.

If you want to learn how React and dotCMS help you build SPAs, you can read the full tutorial here: How to use dotCMS & React to build a SPA.

Filed Under:

Recommended Reading

14 Benefits of Cloud Computing and Terminology Glossary to Get You Started

What is cloud computing, and what benefits does the cloud bring to brands who are entering into the IoT era?

Headless CMS vs Hybrid CMS: How dotCMS Goes Beyond Headless

What’s the difference between a headless CMS and a hybrid CMS, and which one is best suited for an enterprise?

Exploring TimeMachine: How dotCMS Handles Content Versioning

With dotCMS, tools like TimeMachine and Workflow Management help enterprises control content versioning, content edits, user permissions, workflows and more.