Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    SaaS & Tech

    Maximizing Impact: Strategies for SaaS & Technology Marketing

    B2B Leads

    Enhancing B2B Lead Generation with Data and Analytics Strategies

    CSS

    How to build complex layouts with CSS Grid

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Wednesday, September 10
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / PHP / WordPress / Building a WordPress Website with React (Frontity)
    React

    Building a WordPress Website with React (Frontity)

    adeneyeBy adeneyeDecember 21, 2020Updated:May 26, 2024No Comments10 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Building a WordPress Website with React (Frontity)
    Building a Worpress Front-End using React
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Building a Worpress Front-End using React
    Building a Worpress Front-End using React

    According to W3tech, nearly 35% of the websites over the internet are powered by WordPress. The development of WordPress has always been centre around PHP, but as the use of headless CMS grows, you can now seamlessly build fast websites with React and WordPress using a framework like Frontity.

    Frontity is a free and open-source framework with a focus on WordPress that helps you build a React-based frontend for a headless (or decoupled) WordPress site. Although React frameworks like Gatsby.js and Next.js work with WordPress, none of them is exclusively focusing on WordPress. You would normally have to do some complex configuration and additional tooling, Fortunately, Frontity eliminates all these pain-staking and additional tooling developers have to do and gets you to the development stage faster.

    In this tutorial, we will work you through the process of building a WordPress website with Frontity but before that let’s consider how the Frontity works and why it is a better option for your WordPress project.

    What is Frontity

    As described by Frontity, it’s a free and open-source framework that enables you to build a React-based frontend for a headless (or decoupled) WordPress site. After setting up frontity, your WordPress site serves its data via the REST API, Frontity will then consumes this data and render it in the browser as a SPA (Single Page Application) which you can configure and style to your choice.

    Yet, Frontity was created with a focal point on WordPress in mind to make everything simpler, even for developers who are not familiar with React. All aspects of the framework have been simplified and optimized for WordPress. Frontity includes everything you need to build a WordPress without having to figure out what tools to use for things like state management, CSS or any extra tooling. Since you don’t have to set up any additional tooling, it makes building your websites ready-to-go out of the box.

    How Frontity Works

    In Frontity WordPress dashboard is utilized as a headless CMS for creating and managing content the same way you’re used to. As you make changes, your content is automatically updated in your Frontity site as it is when working with a traditional WordPress theme

    Since React is a JavaScript library, the Frontity app needs a Node.js server to run. It requests content from the WordPress REST-API and uses it to generate the final HTML that is displayed in the browser. Moreover, it’s capable of generating AMP pages utilizing the same React code and CSS.

    The diagram below is a visual representation of how Frontity works.

    How Frontity works

    How Frontity worksHere are some of the advantages of using Frontity:

    SSR and SEO Friendly:  Frontity does server-side rendering out of the box. This approach works great with dynamic content and is useful for SEO.

    Extensible: Frontity powers a flexible extensibility pattern like WordPress. Themes and extensions will activate without code changes.

    Lightning Fast Loading:  What I love more about Frontity is the speed in load type. Frontity sends a navigation ready HTML page, that is immediately usable. So the initial load feels almost instant.

    Required Zero Setup: Everything you need to make the connection is already included(React, Webpack, Babel, Routing), So you can jump straight in and start creating your site.

    Easy to Use: Frontity gives you a big head start by taking care of the complexity associated with connecting WordPress to React.

    How to Build a website with Frontity

    These are the list of prerequisite you will need for this tutorial:
    Node JS installed on your computer – If you don’t already have it you can get Node.js from the official site. This will also install npm and npx along with Node.js. You will use these to run Frontity commands during the set-up and development of your project
    A remote WordPress site – (In my case I’m using a friend blog website africanhairinfo.com ). However, you can use the default test site that comes with the Frontity for your demo. so you won’t be without content.

    Read More:  Create simple POS with React, Node and MongoDB #2: Auth state, Logout, Update Profile

    Setting up Frontity

    Frontity has a built-in CLI that enables you to create a new frontity application with a single command.

    To install the frontity CLI:

    npx frontity create my-project

    You should replace the name my-project with your project name. If you’re starting with Frontity then the  Mars theme is a good choice to help you get an idea of how it works.

    You may also decide to subscribe to Frontity newsletter by entering your email after a successful installation then move into your new project directory with the command below.

    cd my-project

    The project directory will contain the following structure:

    my-app/
    |__ node_modules/
    |__ package.json
    |__ frontity.settings.js
    |__ favicon.ico
    |__ packages/
        |__ mars-them

    If you’re new to React, this directory contains the following important Frontity files and folders.

    • Node_modules: This is where all your development dependencies are stored. You shouldn’t need to modify or open any of the files inside these folders.
    • Frontity.setting.js: This is where you will define your project settings and any packages it requires.
    • Package.json: This is a JSON file that will be used to configure all your Node.js projects, it is also where you will store dependencies required by your application.
    • Packages: This folder contains all local packages including your theme.

    To start the development server, run the following command below:

    npx frontity dev

    Once you run the command, the server will be listening to https://locahost:300 and the page will open automatically in your browser. Initially, Frontity will connect to a test blog that displays demo content.

     Frontity Test Blog
    Frontity Test Blog

    You can connect to your WordPress website by editing the frontity.setting.js file, which you will find in the root directory of your project I showed to you earlier.

    To do that, open the file with any programming text editor. Locate this file @frontity/wp-source setting object is at the bottom of the file and change the API property to the address of your website.

    frontity.settings.js
    const settings = {
      ...,
      packages: [
        ...,
        {
          name: "@frontity/wp-source",
          state: {
            source: {
              // Change this url to point to your WordPress API.
              api: "https://test.frontity.io/wp-json/"
            }
          }
        }
      ]
    }

    By default, the API property is set to “https://test.frontity.io/wp-json/” which is the URL that points to the default Frontity WordPress test API. You will need to change the address to point to your WordPress website with the wp-json extension, In our case, I’m changing the API to point to this https://africanhairinfo.com/.

    name: "@frontity/wp-source",
          state: {
            source: {
              // Change this url to point to your WordPress API.
              api: "https://africanhairinfo.com/wp-json/"
            }
          }
        }

    In the code above, don’t forget to add wp-json extension after your website URL, then save your changes and manually refresh the page in your browser. The page should be updated and display content fetched from your website.

    Configure your Menu

    Before I show you what my page looks like after Frontity pulled the data from the WordPress site, the first thing we have to do is to create pages we would like to show on our Frontity theme because the menu still contains links to Frontity’s demo content. To do so find @frontity/mars-theme setting object in frontity.setting.js and update the menu array to the structure of your site.

    frontity.settings.js
    const settings = {
      ...,
      packages: [
        {
          "name": "@frontity/mars-theme",
          "state": {
            "theme": {
              "menu": [
                [
                  // The link to your home page
                  "Home",
                  "/"
                ],
                [
                  // A link to a Contact Us page
                  "Contact Us",
                  "/contact-us/"
                ],
                [
                  // A link to the About Us category
                  "About Us",
                  "/about-us/"
                ],
                ...
              ],
              "featured": {
                "showOnList": false,
                "showOnPost": false
              }
            }
          }
        },
        ...
      ]
    }

    In the above code, I added three menu items (Home, Contact Us, About Us). For example, if you want to link to the website about-us page located at https://africanhairinfo.com/about-us/ you will need to create a link that leads to the about-us in the menu array list.

    Read More:  React Native vs. Flutter: Which One Would Suit You Better?

    You can then save these changes and refresh the website manually while the menu will update the links to all the three pages. Kindly note I’m only accessing the content of just three pages on this website (https://africanhairinfo.com/), not all the pages. However, if you want to access all the content, it’s still the same procedure.

    Updated-Menu
    Updated-Menu

    Customize your Theme

    Frontity takes a different approach to WordPress when customizing themes. It uses CSS in JS instead and also comes with Emotion among its libraries for styling. This allows you to write CSS styles with JavaScript.

    Note that when we first set up Frontity, you selected the Mars theme. This theme controls your site’s appearance, but you can modify the default look of your website by editing the theme located in the package/mars-theme folder.

    To do this styling, open the package/mars-theme folder and navigate to /src which contains index.js file where you can configure your theme, and a /components folder where all the components that are part of your theme are.

    You can also read more about how to style your Frontity theme here.

    To demonstrate the general process, we will be changing the background color of the website header. To do this, locate the <HeadContainer> component in index.js and change the background-color to red.

    const HeadContainer = styled.div`
      display: flex;
      align-items: center;
      flex-direction: column;
      background-color: red;
    `;

    Save the changes and the new color will be applied immediately.

    Changes-Applied
    Changes-Applied

    You can try to explore the theme files and folders to modify changes to help your websites stand out.

    Publish your Websites

    After you have added feature and style to your website, you can now deploy it to production.  It is similar to how easy a new site is a scaffold and runs in development.
    Run the following command from the root of your project to create a production-ready bundle:

    npx frontity build

    This will create a build folder containing your React application and Frontity(Node.js) server. This folder can be deployed to any hosting that is prepared to serve a Node.js application. For example, npx frontity serve can be used to run your project like a standard Node.js application, or upload it to a CDN(Content Delivery Network) and serverless service.

    However, you could also use AWS lambda, Netlify, or Google Functions but Frontity recommended Vercel as a serverless solution.

    To do so, you can use Vercel and follow these steps:
    https://docs.frontity.org/deployment/deploy-using-vercel

    Also, don’t forget to create a vercel.json file containing the following file on the app root directory.

    {
      "version": 2,
      "builds": [
         {
           "src": "package.json",
           "use": "@frontity/now"
         }
      ]
    }

    Vercel will give you a default domain like this your-project-name.vercel.app that will allow you to check your site online. You can also configure your site under a custom domain.

    By now your website is published and ready to be view by anybody.

    Conclusion

    In this tutorial, we have seen how to use Frontity to build a website with WordPress and React. Frontity makes WordPress-React development easier by reducing the workload typically required to create a headless WordPress website.

    If you also need any help, Frontity has a great community around it.

    I will also be in the comment section below to answer any of your questions.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    adeneye

      Related Posts

      JAMstack Architecture with Next.js

      March 15, 2024

      Rendering Patterns: Static and Dynamic Rendering in Nextjs

      March 7, 2024

      Handling Mutations and Data Fetching Using React Query

      September 12, 2023
      Leave A Reply Cancel Reply

      You must be logged in to post a comment.

      Stay In Touch
      • Facebook
      • Twitter
      • Pinterest
      • Instagram
      • YouTube
      • Vimeo
      Don't Miss
      Node.js February 5, 2021

      Nodejs Lesson 16: Internals of Nodejs: Event Loop

      This lesson will continue the last lesson where we learned how the LibUV library works internally. In this lesson, we will learn about Event Loop and understand various terms like call stack, callback queue, etc. Let’s start.

      React Lesson 5: React Devtools and Reusable Open-Source Components

      December 20, 2019

      Nodejs Lesson 15: Internals of Nodejs: LibUV

      February 4, 2021

      Strategies for Identifying Quality LinkedIn Prospects by Niche

      December 7, 2024

      Categories

      • AI & Automation
      • Angular
      • ASP.NET
      • AWS
      • B2B Leads
      • Beginners
      • Blogs
      • Business Growth
      • Case Studies
      • Comics
      • Consultation
      • Content & Leadership
      • CSS
      • Development
      • Django
      • E-commerce & Retail
      • Entrepreneurs
      • Entrepreneurship
      • Events
      • Express.js
      • Facebook Ads
      • Finance & Fintech
      • Flask
      • Flutter
      • Franchising
      • Funnel Strategy
      • Git
      • GraphQL
      • Home Services Marketing
      • Influencer & Community
      • Interview
      • Java
      • Java Spring
      • JavaScript
      • Job
      • Laravel
      • Lead Generation
      • Legal & Compliance
      • LinkedIn
      • Machine Learning
      • Marketing Trends
      • Medical Marketing
      • MSP Lead Generation
      • MSP Marketing
      • NestJS
      • Next.js
      • Node.js
      • Node.js Lessons
      • Paid Advertising
      • PHP
      • Podcasts
      • POS Tutorial
      • Programming
      • Programming
      • Python
      • React
      • React Lessons
      • React Native
      • React Native Lessons
      • Recruitment
      • Remote Job
      • SaaS & Tech
      • SEO & Analytics
      • Soshace
      • Startups
      • Swarm Intelligence
      • Tips
      • Trends
      • Vue
      • Wiki
      • WordPress
      Top Posts

      Mastering B2B Lead Generation: A Complete Guide for Success

      B2B Leads November 28, 2024

      D3.js and Angular/Vue.js Integration

      Programming November 29, 2017

      All You Should Know About Web Development in 2020 [Trends]

      Trends December 18, 2019

      TOP 11 JavaScript Machine Learning & Data Science Libraries

      JavaScript August 27, 2019

      Subscribe to Updates

      Get The Latest News, Updates, And Amazing Offers

      About Us
      About Us

      Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

      7901 4th St N, Suite 28690
      Saint Petersburg, FL 33702-4305
      Phone: 1(877)SOSHACE

      Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
      Our Picks
      POS Tutorial

      Create simple POS with React.js, Node.js, and MongoDB #11: CRUD with Relation

      Programming

      Angular 2, part 2

      Events

      Soshace Becomes a Media Partner of Running Remote in Bali

      Most Popular

      Mastering N-API and Native Modules in Node.js

      JavaScript

      Effective Strategies to Boost B2B Lead Conversion Rates

      B2B Leads

      Advanced Mapmaking: Using d3, d3-scale and d3-zoom With Changing Data to Create Sophisticated Maps

      JavaScript
      © 2025 Soshace Digital.
      • Home
      • About
      • Services
      • Contact Us
      • Privacy Policy
      • Terms & Conditions

      Type above and press Enter to search. Press Esc to cancel.