Building websites with a Headless CMS and Modern Javascript Frameworks

We explore three big trends: Headless CMS, Reactive Frameworks and Component-Based Design. We build the page in Gatsby, the component in React and do content modeling in Prismic.

gatsby and prismic

Headless CMS and Reactive Frameworks

A Headless CMS focuses entirely on content and stays away from its presentation. As web content gets strategic, it is used in several places beyond the main website. Headless CMS enables this by providing “Content-as-a-Service” where the content can be accessed with clean and modern APIs. Products such as Contentful, Prismic and others are leaders in this space.

At the same time, front-end technologies have been advancing rapidly. Reactive frameworks such as React, Angular and Vue have been primarily used for web applications until now. Modern javascript frameworks such as Gatsby, Jekyll, Hugo, Next have begun to make them accessible to the traditional website world as well.

Another major trend has been towards component-based design and development for websites. While component-based design systems have been quite common in product design (Eg. Salesforce Lightning, IBM Carbon and AirBnB ) they have been somehow overlooked in websites as they’re one-off builds and don’t have ongoing dedicated teams. They also tend to be quite distinctive and built by outside firms – both of which preclude this sort of rigor. However, with websites getting larger, more sophisticated and critical, this thinking is beginning to change. For a more detailed post that introduces component-based design in websites, click here.

In this post, we explore all three trends by building a page that contains a sophisticated dynamic component. This page is built in Gatsby, the component is built in React and the content modeling is done in Prismic.

The “Case Study” Dynamic Component

Exemplifi — where we work at — is an enterprise website development firm. We build sites for clients and we typically partner with a design agency to accomplish this. The end result is a successful customer for which we have a case study on our website. This case study describes how the customer’s site was built, what CMS platform was used and how this was integrated into their marketing tech stack. Furthermore, we have website build solutions for different industries and want to highlight them along with case studies relevant to a particular industry.

To build a truly data-driven dynamic website, we had to model these relationships in a database schema and have that database power the entire site. The schema for the business looked something like this.

business entity diagram

The case study component looks like below:

website page sample

At its most basic, the component has to display the entire list of case studies and organize it by industry. There are a few other requirements. The overall website organization is shown below:

CMS platforms industries and design partners

When a user clicks on WordPress, the case study component should show only WordPress case studies and organize it by Industry. Similarly, for the healthcare page, it should show only healthcare case studies. Finally, on the design partner page, it should show only case studies that we collaborated with that design partner on.

Clearly, a sophisticated component with detailed functionality!

Content Modeling in Prismic

We created the content types and relationships in Prismic:

content modeling in prismic

The detailed case study content definition is shown below along with all the associated relationships:

case study page

As you can see, Prismic provides the ability to create relationships between different entities:

relations in prismic

Case study content is eventually created as follows:

case study creation in prismic

This content is then exposed by creating an API  endpoint with an access token.

api creation in prismic

Setting up the Gatsby Framework

Gatsby is a static website generator that uses React, Node and GraphQL. The framework creates HTML files for each page. When building the website, Node mounts the React application and creates HTML files with the rendered content for each route.

You can configure the gatsby-source-prismic plugin to access the content in Prismic via the access token that we created earlier. Finally, all corresponding nodes in the Gatsby server can be queried through GraphQL.

setting up the gatsby framework

Netlify is an excellent option for deploying Gatsby sites. Netlify is a unified platform that automates your code to create performant and easily maintainable sites. They provide a lot of devops features: continuous deployment (Git-triggered builds), CDN, DNS mapping, SSL and asset acceleration.

To deploy our project we created a git repository and connected it with Netlify. Code pushes automatically trigger netlify to build the project with necessary dependencies and provide a preview URL like so:

netlify connection with git repository

Building the Case Study Component in React

The gatsby-source-prismic plugin consumes content from the Prismic API and creates nodes that can be accessed through the GraphQL query. Config in the gatsby-config.js file is shown below:


    resolve: `gatsby-source-prismic`,

    options: {

      repositoryName: `exemplifi`,

      accessToken: `${process.env.API_KEY}`,



After this is setup, we access the case study nodes through GraphQL and store it in the React props:

code snippet

As shown in the image below, the react component is embedded into different templates that power different pages on the site:

templates for react components

For eg. the page would be powered by the CMS Template. On the drupal page the CMS template would pass the “CMS = Drupal” parameter to the react component. On the WordPress page, the template would pass “CMS = WordPress” parameter to the react component. Similarly the page would be powered by the Industry Template.

It is important to note that the React component is exactly the same on all these templates. It merely accepts parameters and outputs different content based on what’s passed to it.

As you can see below, the react component is embedded in the post.jsx template (for the industry pages). It accepts a list of all case studies and the industry.

code snippet

The React Component is shown below:

react code snippet

Essentially, it iterates through the entire list of case studies, filters by the industry and shows only those. This is how it looks to the user on the /healthcare page

healthcare website sample

and this is how it shows on the /insurance page:

insurance page sample

Quick Note on Performance

The key selling point of this tech stack is that it is supposed to be really fast. We did a quick check on Google PageSpeed Insights and it is indeed true! Admittedly this is a simple page but getting a score of 90 (for mobile) with such sophisticated dynamic functionality is quite a good thing.

google page speed insights


We explored three big trends: Headless CMS, Reactive Frameworks and Component-Based Design. We built the page in Gatsby, the component in React and did content modeling in Prismic.

No items found.

Related Insights

Migrating Government Websites to the Latest CMS Platform

We discuss how to migrate and keep government websites secure, up to date and ready for changes in technology.

Ashwin Thapliyal

CMS Trends

Component Design in a Headless CMS

We discuss how to implement component-based design in a Headless CMS platform (VuePress)

Anirudh Mahant

CMS Trends

Subscribe to our newsletter