Getting Started with Frontity

Getting Started with Frontity

Frontity is an open source React framework for WordPress. Frontity provides a seamless connection between WP’s REST API and your React app. Without Frontity, this connection is much more complex to configure.

This tutorial provides those new to Frontity with a crash course in how to connect WordPress's Rest API to a React app.

As described on its landing page, Frontity is an open source React framework for WordPress. In essence, it works as a dynamic framework for headless WordPress sites and blogs.

Frontity provides a seamless connection between WP’s REST API and your React app. Without Frontity, this connection is much more complex to configure.

Running Frontity

For this tutorial, we’re going to assume you already have Node.js installed.

To get started with a Frontity project, all you need to do is to run the following:

npx frontity create my-app

Follow the prompt and wait for the dependencies to get installed. Once this is finished, you can get into your app with cd my-app , and then use npx frontity dev to start the server.

Frontity helps set up everything you need from bundling to server rendering. Right away, you’ll be ready to start connecting, styling, and deploying.

Setting up

The magic of Frontity happens in the frontity.settings.js file. Just by changing the state.source.api attribute, we’ll be able to pull all the posts available in your common WP website.

Right here, you can edit most of the available configuration: the menu, the router module, multiple sites, components, packages, head tags and much more.

A full overview of the configurations you can work with in this file is available here in the docs. It is as simple as working with a small JSON file.

How it works

Right from the file structure, a Frontity project doesn’t look like a regular React application. This is an opinionated design choice and it is great at what it does. Your app’s code is grouped into packages, just like in the node_modules folder, and Frontity makes them interact.

There are two types of packages available in Frontity:

Core packages including frontity and @frontity/core These packages contain the core of Frontity and need to be installed in any Frontity project.

Frontity packages including @frontity/wp-source , @frontity/tiny-router or @frontity/my-theme . These need to be declared in the settings file. They’re similar to WordPress theme and plugins. You can change them if you want, add more, or create new ones.

When installing the app, the core packages are automatically installed.

react frontity wordpress api web-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

How native is React Native? | React Native vs Native App Development

Article covers: How native is react native?, React Native vs (Ionic, Cordova), Similarities and difference between React Native and Native App Development.

Hire WordPress Developer

Whether you want to develop a blog or you want a feature-rich, interactive WordPress website? **[HourlyDeveloper.io](https://hourlydeveloper.io/ "HourlyDeveloper.io")** is a distinguished leader in the WordPress development market. **[Hire...

Best WordPress Development Services in India

Skenix Infotech is a top WordPress Website Development Company in India & USA with expert WordPress Developers. Get affordable WordPress Development Services.

Hire Dedicated Wordpress Developer

Find the latest jobs available in The Middle East today.

WordPress Development Company in India

Skenix Infotech is a top WordPress Website Development Company in India & USA with expert WordPress Developers. Get affordable WordPress Development Services.