React starter with Contentful

Building a React application with Contentful is straightforward — with help from this guide that is!

Build your image gallery with Contentful and React

This React starter shows you how to use the Contentful API to retrieve data from the headless React CMS, display entries using React components, and filter those entries using Contentful tags and React hooks.

View tutorial

What is React?

React is an open-source JavaScript library created by Meta. It lets you build user interfaces for your web applications by breaking your UI into small, reusable, encapsulated pieces called “components.”

1

Source code and dependencies

Create a new React project on your local machine using our React + Contentful starter template.

Clone the repository.

2

Create account and secrets

Create a Contentful account with an empty space. Go to your Contentful space and

3

Create an environment file

Copy the “.env.example” file in your cloned repository. Rename it “.env.”

Update your “.env” file with the Space ID, Content Management Token, and Content Delivery Token from your Contentful space.

4

Set up the content model

This project comes with a Contentful set up command that imports the required content model and adds sample content to your space.

Run the command below to set up the content model. This will require your environment file from the previous step.

5

Run the development server

In the terminal run:

Your browser will automatically open and navigate to localhost:1234

You should see a simple website with interactive checkboxes.

From there, you should be able to filter out images based on the tags you’ve set in Contentful.

Starter guides

Your stack, your rules - power your projects with a fully extensible content platform

Get hands-on with guided tutorials, videos, and starter toolkits tailored for the languages and frameworks you use every day.

    View starter guides
    React Starter with Contentful | Contentful