• React in South Africa
  • Database included
  • First month free

How to Host a React App (and Its Backend) in 2026

Learn how to host a React app and its backend: where the frontend goes, where the API and database live, and three things that break React apps after launch.

Your React build finishes, and you're left looking at a dist folder full of files with names like index-a8f3c2.js. Job done? Not quite. Your app still needs to log people in, save bookings, and talk to a database, and none of that lives in that folder.

That's the part most hosting guides skip. This guide explains how to host a React app properly: where the frontend goes, what to do with the backend and database behind it, and the three things that most often break React apps after launch. If you're new to app hosting in general, our guide to web app hosting covers the basics first.

Key Takeaways: How to Host a React App

  • A React app builds to static files, so the frontend itself is easy to host almost anywhere.
  • Most real React apps also need a backend and a database, and that's where hosting choices start to matter.
  • Anything in a React build is visible in the browser. API keys and passwords belong in the backend, never in the frontend.
  • Single-page apps need routing support on the host, or refreshing a page shows a 404.
  • HCode hosts your React frontend, its API, and a PostgreSQL database together in South Africa, from R50 a month.

What Does It Take to Host a React App?

Hosting a React app means serving its production build to visitors, and usually running a backend beside it.

On your laptop, your React project runs through a development server. For production, the app is built once. Your host (or you) runs npm install to fetch the dependencies, then npm run build, which compiles the whole React project into a folder of plain HTML, CSS, and JavaScript files. With Vite, that folder is called dist. With Create React App, it's build.

A quick note on Create React App: it's no longer recommended for new projects. The React team now points new projects to a framework, or to a build tool like Vite. Existing Create React App projects still build and host the same way.

Most modern hosts connect straight to your Git repository. Each time you make a git commit and push it to the git remote, the host pulls the new code, runs the build, and publishes the result. That's continuous deployment, and once it's set up, you rarely think about it again.

Client-Side vs Server-Side React

A plain React app runs client side, in the visitor's browser, which is why its build is just static files.

Most React apps built with Vite are single-page applications. The browser loads one HTML page and some JavaScript, and React Router swaps the content as people click around. No server builds pages along the way, so a static host can serve the whole frontend.

React frameworks work differently. Next.js and similar frameworks can render pages server side for each visitor, or build them ahead of time with static site generation. Server-rendered pages need a running Node.js server, which changes where you can host them. If that's your setup, our guide on how to host a Next.js app covers it.

Plain React (Vite)React framework (such as Next.js)
Where pages are builtIn the browserOn the server, or ahead of time
Hosting the frontend needsStatic file hostingUsually a Node.js server
Backend and databaseA separate APICan live in the same app

Where to Host a React App: Your Options

You can host a React app on four main types of hosting. The right one depends on whether your app has a backend.

Static hosts serve your build from a global CDN, so files load quickly almost anywhere. They're a good fit for a frontend on its own, but they don't run backend code. GitHub Pages is a common free option for demos and portfolios, with the same limit.

Shared hosting can serve a React build, since it's just files. It's built mainly for PHP websites, though, so running a Node.js or Python API beside your React app is usually off the table.

A VPS can run everything: the React build, the API, and the database. You set it all up and look after it yourself.

A managed app platform builds and serves your React app for you, and the better ones run your API and database alongside it. It's the closest thing to a full stack setup with nothing to maintain.

OptionServes the React buildRuns your APIDatabase
Static hostYesNoSeparate service
Shared hostingYesRarelyUsually MySQL
VPSYes, once you configure itYesYou install it
Managed app platformYesYes, on mostOften included

The Part Most Guides Skip: Your React App's Backend

A React app with a backend needs two things hosted, not one: the frontend, and the server code and database it talks to.

Most web apps built with React aren't just pages. They log people in, take payments, and save data, and that work happens on the server side, usually in a Node.js or Express API, or a Python backend built with Django or Flask. That API then reads and writes to a database such as PostgreSQL.

Why your keys can't live in React. Environment variables in a React build aren't private. Vite bakes any variable starting with VITE_ into the JavaScript it ships (Create React App does the same with REACT_APP_), so anyone can read them in their browser. Payment keys, database passwords, and private API tokens belong in your backend's environment variables, where visitors can't see them.

Why splitting the two gets messy. Plenty of teams host the React frontend in one place and the API somewhere else. It works, but you end up with two accounts, two bills, two sets of settings, and extra configuration so the frontend is allowed to call the API on another address.

Keeping the frontend, the API, and the database on one platform avoids all of that. See how HCode runs Node.js, Express, Python, and PostgreSQL alongside your React app.

Diagram of a React app on HCode: the visitor's browser loads the React frontend, which calls an API, which reads from a PostgreSQL database, all hosted in South Africa.

Three Things That Break React Apps After Launch

Most React apps that work locally but break in production fail in one of three ways, and a good host prevents all three.

  1. A 404 when someone refreshes a page. React Router handles pages like /about in the browser, so there's no about file on the server. Unless the host sends unknown paths back to index.html, a refresh or a shared link shows a 404.
  2. A blank page with no error. The build looks for its files in the wrong place, usually because the output folder or base path doesn't match where the site is served.
  3. Keys that anyone can read. A secret placed in a VITE_ or REACT_APP_ variable ends up in the browser for anyone to see.

On a VPS, you fix the first two in your web server and build settings, and our React VPS tutorial shows you how. On HCode, the first is handled automatically, the second is caught and named before a broken release goes live, and the third has a proper home: your API's environment variables, in a backend project right beside your frontend.

How to Host a React App on HCode

HCode is HostAfrica's managed app platform, and it hosts your React frontend, its API, and its database in one place. Getting started takes three steps:

  1. Pick a plan. Choose one on the React hosting page and order it in the HostAfrica client panel. Plans start at R50 a month, and code HCODEFREE2026 makes your first month free.
  2. Connect your code. Link your GitHub repository or upload a .zip.
  3. Push. HCode runs the build, recognises the static output from Vite or Create React App, and serves it over HTTPS. Every push after that deploys again.
What a React app needsOn HCode
Build and serve the frontendStatic output detected and served automatically, with no web server to configure
React Router supportSingle-page apps get index.html for unknown paths, so refreshes and shared links work
Safe releasesEach deploy checks the site loads; a broken release never replaces the live one
Continuous deploymentEvery git push builds and deploys a fresh version
An API beside itRun a Node.js, Express, or Python backend as its own project on the same platform
A databaseManaged PostgreSQL or Redis included, backed up daily
Custom domains and SSLA free subdomain straight away, then your own domain with automated SSL

Everything runs in South Africa, on one flat price in rand. And if a release misbehaves, you can roll back to the last good one in a click.

Prefer to Run It Yourself?

If you'd rather set up the server by hand, a VPS gives you full control over Nginx, caching, and everything else. Our step-by-step guide shows you how to deploy a React app from GitHub to a VPS, including the Nginx setting that keeps React Router working.

FAQs: Hosting a React App

Where Should I Host a React App?

It depends on your backend. A frontend on its own can go on almost any static host. If your app has an API and a database, host them together on a managed app platform or a VPS, so the pieces sit side by side.

Does React Need a Server?

A plain React app doesn't need a server to run, because it builds to static files. Its backend does, though, and frameworks like Next.js need a Node.js server for server-rendered pages.

Can I Host a React App for Free?

A static React frontend can be hosted for free on services like GitHub Pages, within their limits. Once the app needs a backend and a database, you'll need paid hosting. On HCode, code HCODEFREE2026 gives you your first month free.

Can I Host a React App and a Node.js Backend Together?

Yes. On HCode, your React frontend and your Node.js or Express API run as separate projects on the same platform, with PostgreSQL beside them and one bill in rand.

Does HCode Support React Router?

Yes. HCode recognises single-page apps and serves your index.html for paths that aren't files, so refreshing a page or opening a shared link works without extra setup.

How Do I Keep API Keys Out of My React App?

Keep them in your backend. Anything in a React build, including VITE_ and REACT_APP_ variables, is visible in the browser. Put secrets in your API's environment variables, and have the frontend call the API instead.

Avatar for Ashwin S.

The Author

Ashwin S.

Ashwin is a content specialist at HostAfrica, where he's been crafting clear, authoritative copy since 2021. With a background in digital marketing and a passion for impactful storytelling, he turns complex ideas into trustworthy, engaging content. Ashwin writing helps our audience navigate web hosting and cloud solutions with confidence.

Your React App, Backend Included

Push your code, and HCode serves your React frontend, runs your API, and keeps your database right beside them. One flat price in rand.

Your first month is on us with codeHCODEFREE2026