A React app interacts with the user dynamically. It avoids interruptions of the user experience between successive pages. It rather appears to be a desktop application than a website.
You can do quite a lot with a React web-app. Even if it has no backend.
- You can server different routes. React adds the path of a route after a
#. Usually, anything after the
#is ignored. But React-Router uses this information and provides it to your web-app.
- You can work with local states. React provides the
useState(), useEffect()-hook and supports a Redux-store
- You can call any API. You can send or fetch data.
Why would your app need a backend?
Maybe you need to write your own web-services. Services that access your database. Services that cater to the specific needs of your app. Services that provide the exact data your app needs in the exact format your app needs.
Maybe you need to render your web-app at the server-side. Completely rendered HTML pages enable search engines to crawl the content of your app.
Maybe your app needs to open socket-communication to support real-time events.
There are plenty of good reasons, why your app needs a backend. If your app needs a backend to achieve its purpose, then go ahead.
There are some great backend options for React. Some reasons:
Integration with other 3rd party systems
But what if your app does not yet really need a backend?
When you start coding your React app, you may not know for sure whether you would need a backend later.
This best practice in software development tells you to not add anything to your code until you actually need it. You implement the code you need to solve your problem at hand. Not more.
But a backend is nothing that adds to your app. It changes your app! For instance, whether you do client-side rendering or server-side rendering determines the whole architecture of your app. Changing it means rewriting large parts of your app.
One of the best implantation is integrating React with Django, which enhances the website’s look in ways that is just not possible via django. It worth both ways. So, particularly in this case backend needs React and not the other way around.
Another implementation when React does need backend is when using cloud storage such as Firebase for storing data securely.
If you don’t need a backend right now, then don’t implement it. And once you do, it is not too late to add it.