So you started building your React app and you realized that you need someplace to store the data. While you can save the data in the browser using the Web Storage (i.e. localStorage or sessionStorage) or IndexedDB APIs, most React apps store the data on the server or the backend so that it can be loaded on other devices.

If you want to set up a backend for your React app, you have two options.

In most cases, I recommend that you use a BaaS instead of building your own backend. If you are a beginner, this will let you focus on the frontend without adding even more things to your learning plate. For everyone else, it will greatly reduce the development time since a lot of functionality is provided for you.

Using a backend as a service (BaaS) platform

Most web apps send and receive data from a server (CRUD operations) and identify users to determine which data to display (authentication). Since this functionality is so common, many platforms provide this functionality for you without you having to implement it from scratch. These platforms are commonly known as backend as a service (BaaS) and here are a few that I would recommend.

All of these platforms provide a Javascript library that you can use to save and retrieve data from a database and handle user authentication. They also have extra functionality such as real-time database updates and cloud functions for running custom logic.

If you are a beginner or you are building a small application, I recommend that you go with Firebase since it offers the most services and is also the most popular.

Building your own backend

Building your own backend is still the best way to familiarize yourself with backend development. In addition, building your own backend gives you complete control over the server hardware and the data structures in the API which is useful when you want to improve performance.

When you build your own backend, you need to design and provide a REST API for the React app to use. You can implement this API with many different languages and frameworks but here are a few approaches with the most popular server-side languages (PHP, NodeJS, Python)

I strongly recommend going with NodeJS because you don't have to learn a separate language. Since it is commonly paired with React, there are also more guides that walk you through how you can implement functionality across both.

Prabashwara Seneviratne

Written by

Prabashwara Seneviratne

Author. Lead frontend developer.