Deploying your application is one of the most exciting parts of web development. After spending hours building features, authentication, payments, and dashboards, itβs finally time to make your application accessible to everyone.
In this guide, you'll learn how to deploy a modern full-stack application where:
- βοΈ React (Vite) is hosted on Firebase Hosting
- π Express.js backend is deployed on Render
- ποΈ PostgreSQL (Neon/Supabase or any hosted database) remains online
- π Environment variables stay secure
- π Your frontend communicates with your backend in production
By the end of this tutorial, you'll have a production-ready deployment pipeline suitable for portfolios, personal projects, and even startup MVPs.
ποΈ Final Architecture
Users
β
βΌ
Firebase Hosting (React)
β
HTTPS API Requests
β
βΌ
Render (Express API)
β
βΌ
Database (Neon/PostgreSQL)
Separating the frontend and backend makes your application easier to scale, maintain, and deploy independently.
π Prerequisites
Before starting, make sure you have:
- Node.js installed
- Firebase account
- Render account
- GitHub repository
- Production database (Neon, Supabase, PostgreSQL, etc.)
- React frontend
- Express backend
Example project structure:
Ecommerce/
β
βββ client/
β βββ src/
β βββ public/
β βββ package.json
β
βββ server/
βββ controllers/
βββ routes/
βββ middleware/
βββ app.js
βββ package.json
π€ Why Firebase + Render?
This combination is perfect for modern React applications.
π₯ Firebase Hosting
- Global CDN
- HTTPS by default
- Extremely fast
- Easy deployment
- Excellent for React/Vite projects
π Render
- Free starter tier
- Automatic GitHub deployments
- Environment variable support
- SSL included
- Great Express support
Step 1 β Prepare Your Backend
Before deployment, make sure your backend works locally.
npm install
npm run dev
Visit:
http://localhost:5000
Ensure your API responds correctly.
Step 2 β Configure Environment Variables
Never hardcode secrets.
Create a .env file:
PORT=5000
DATABASE_URL=your_database_url
JWT_SECRET=your_secret
STRIPE_SECRET_KEY=your_key
CLIENT_URL=http://localhost:5173
Never commit this file.
Instead, add it to .gitignore.
.env
Step 3 β Configure CORS
When the frontend is hosted on Firebase, Express must allow requests from that domain.
app.use(
cors({
origin: [
"http://localhost:5173",
"https://your-app.web.app",
"https://your-app.firebaseapp.com",
],
credentials: true,
})
);
Later you'll replace these URLs with your production Firebase domain.
Step 4 β Push Your Backend to GitHub
Initialize Git if necessary.
git init
Commit your project.
git add .
git commit -m "Initial deployment"
Push to GitHub.
git push origin main
Step 5 β Deploy Express Backend to Render
Login to Render.
Create:
New +
Choose:
Web Service
Connect your GitHub repository.
Select your backend repository.
Build Command
npm install
Start Command
npm start
or
node app.js
depending on your project.
Root Directory
If your backend lives inside:
server
Set:
Root Directory = server
Environment Variables
Add every variable from your .env.
Example:
DATABASE_URL
JWT_SECRET
STRIPE_SECRET_KEY
CLIENT_URL
Render securely stores these values, so they are never committed to Git.
Step 6 β Wait for Deployment
Render will:
- Clone your repository
- Install dependencies
- Build the application
- Start the server
Eventually you'll receive:
https://your-api.onrender.com
Test it.
Example:
https://your-api.onrender.com/api/products
If you receive JSONβ¦
π Congratulations! Your backend is live.
Step 7 β Update Frontend API URL
Instead of:
axios.get("http://localhost:5000/api/products");
Use environment variables.
VITE_API_URL=https://your-api.onrender.com
Create an Axios instance.
import axios from "axios";
export default axios.create({
baseURL: import.meta.env.VITE_API_URL,
});
Now your frontend automatically switches between development and production.
Step 8 β Prepare React for Production
Install Firebase CLI.
npm install -g firebase-tools
Login.
firebase login
Initialize hosting.
firebase init hosting
Choose:
Existing Firebase Project
Hosting
For the public directory enter:
dist
When prompted:
Single Page Application?
Choose:
Yes
Do not overwrite index.html.
Step 9 β Build React
npm run build
This generates:
dist/
Your production build is ready.
Step 10 β Deploy to Firebase
firebase deploy
Firebase provides:
https://your-project.web.app
and
https://your-project.firebaseapp.com
Your React application is now served globally over HTTPS.
Step 11 β Update Backend CORS
Replace:
origin: ["http://localhost:5173"];
with:
origin: [
"http://localhost:5173",
"https://your-project.web.app",
"https://your-project.firebaseapp.com",
];
Redeploy your backend.
Step 12 β Test Everything
Visit your Firebase URL and verify:
- β Home page
- β Authentication
- β Login
- β Register
- β Products
- β Categories
- β Cart
- β Orders
- β Stripe Checkout
- β Protected routes
- β Logout
Open Developer Tools.
There should be:
- β No CORS errors
- β No 404 errors
- β Successful API requests
π‘ Production Tips
π Use HTTPS Everywhere
Both Firebase and Render provide HTTPS by default.
Never mix HTTP and HTTPS.
π Keep Secrets Secure
Never expose:
- JWT Secret
- Stripe Secret Key
- Database URL
Only variables beginning with:
VITE_
should be exposed to the frontend.
π Enable Automatic Deployments
Every push to GitHub can automatically trigger a deployment on Render, making continuous delivery effortless.
β Common Deployment Errors
CORS Error
Access-Control-Allow-Origin
Fix
Add your Firebase domain to Express CORS.
API Not Found
404
Check your Axios baseURL.
Blank React Screen
Usually:
npm run build
failed.
Always build locally first.
Environment Variables Missing
Restart your Render service after updating environment variables.
Wrong Build Folder
For Vite, use:
dist
not
build
β Deployment Checklist
- β Backend deployed
- β Database connected
- β Environment variables added
- β Firebase Hosting configured
- β React built
- β Axios uses production URL
- β CORS updated
- β HTTPS enabled
- β Everything tested
π Conclusion
Congratulations!
You now have a fully deployed modern full-stack application with:
- βοΈ React hosted on Firebase Hosting
- π Express running on Render
- ποΈ PostgreSQL hosted online
- π Secure environment variables
- π Production-ready frontend/backend communication
This architecture is simple, scalable, and perfect for portfolios, personal projects, and startup MVPs.
As your application grows, you can further improve it by adding:
- Custom domains
- CI/CD pipelines
- Monitoring
- Logging
- Docker
- Automated testing
Happy coding! π
π₯ Prefer Watching Instead?
This article accompanies Part 18 of my Modern React E-Commerce Series, where I walk through the complete deployment process step by step.
In the video you'll learn:
- π Deploy an Express backend to Render
- π₯ Host a React (Vite) frontend on Firebase Hosting
- π Configure production environment variables
- π Handle CORS correctly
- π Connect frontend and backend
- β Deploy a real-world full-stack application from start to finish
If you're building along with the series, this lesson completes the journey by taking your application from local development to a live production deployment.
π Watch Part 18
https://www.youtube.com/watch?v=3LMJjIwZDx0&list=PL_02r0p8Ku_6tR8L-n-yj7MW8rrMtswwk&index=18
π Continue Learning β Complete React E-Commerce Playlist
If you're interested in building a production-ready e-commerce application from scratch, check out the complete playlist on my YouTube channel Codeek.
The series covers:
- βοΈ Modern React
- π¨ Chakra UI
- π React Query
- π¦ Zustand
- π³ Stripe Payments
- ποΈ Express.js Backend
- π PostgreSQL
- π Firebase Hosting
- βοΈ Render Deployment
- π Project Architecture
- π Complete E-Commerce Development
Whether you're preparing for interviews, building your portfolio, or creating your next startup, this series walks you through every step with practical, real-world examples.
β If you find the tutorials helpful, consider subscribing to Codeek and sharing the playlist with fellow developers.
Happy coding! π
Top comments (0)