Building MovieFlix: A Complete Movie Explorer App with React, Firebase, TMDB & TailwindCSS


π¬ Introduction
Welcome to my blog! I'm Chirag Tyagi, a B.Tech CSE student and aspiring full-stack developer. In this post, Iβll take you through the journey of creating MovieFlix β a full-featured movie explorer app built with React, powered by Firebase for authentication, and integrated with TMDB API to fetch real movie data.
π Live Demo β
π GitHub Repository β
π οΈ Tech Stack
React + Vite: Fast, modern front-end framework and tooling.
TailwindCSS: Utility-first CSS for rapid UI development.
Firebase: For Google & Email authentication.
TMDB API: For fetching trending, popular, and top-rated movies.
Axios: For HTTP requests.
React Router DOM: For page navigation.
React Context API: Global state for handling favorite movies.
LocalStorage: Persistent favorites.
React Fast Marquee: For smooth background poster animation.
π§ Example: Firebase Auth Implementation
import { createUserWithEmailAndPassword } from "firebase/auth";
const signup = (email, password) => {
return createUserWithEmailAndPassword(auth, email, password);
};
π§ Example: Axios API Fetch
const fetchMovies = async () => {
const res = await axios.get(`https://api.themoviedb.org/3/trending/movie/day`, {
params: {
api_key: import.meta.env.VITE_TMDB_API_KEY,
language: "en-US"
}
});
setMovies(res.data.results);
};
π§ Example: Context API for Favorites
const addToFavorites = (movie) => {
setFavorites(prev => {
if (!prev.some(f => f.id === movie.id)) return [...prev, movie];
return prev;
});
};
π Folder Structure Overview
src/
βββ components/ # Reusable UI components
βββ contexts/ # Auth and Movie context providers
βββ hooks/ # Custom hooks like useAuth
βββ pages/ # Page-level components (Home, Login, Signup, Favorites)
βββ services/ # API logic (TMDB requests)
βββ utils/ # Helpers like genre mapping
βββ App.jsx # Main app component
βββ main.jsx # Entry point
π Firebase Authentication
Email/password login
Google OAuth
Session persistence with
onAuthStateChanged
π¦ Code Example
useEffect(() => {
const unsubscribe = onAuthStateChanged(auth, (currentUser) => {
setUser(currentUser);
setLoading(false);
});
return unsubscribe;
}, []);
π Movie API Integration with TMDB
Stored API Key in
.env
Used Axios to fetch movie lists
Displayed posters, titles, genres, overview
π§ Sample Genre Mapping Code
export const getGenreNames = (ids) => ids.map(id => genreMap[id] || "Unknown").join(", ");
πΌοΈ Movie Cards + Favorites
Poster, title, release year, TMDB rating
On hover: shows overview and genre
Heart icon toggles favorite state
π¦ Code Sample
<button
onClick={onFavoriteClick}
className={favorite ? "text-red-500" : "text-white"}
>
β₯
</button>
π¨ Animated Poster Background with react-fast-marquee
Smooth animation using
react-fast-marquee
Different layers for trending, top-rated, and popular
π¦ Code Snippet
<Marquee speed={60} gradient={false}>
{posters.map(url => (
<img key={url} src={url} className="w-64 h-[24rem] object-cover mx-3 rounded-xl" />
))}
</Marquee>
π Search & Genre Mapping
Search field fetches data from
/search/movie
Genre names displayed using mapped
genre_ids
π¦ Code Snippet
<p className="text-sm text-gray-400">
Genres: {getGenreNames(movie.genre_ids)}
</p>
π Pages and Routing
/
β Home/login
β Login/signup
β Sign-up/favorites
β Protected route
π¦ Protected Route Code
const PrivateRoute = ({ children }) => {
const { user } = useAuth();
return user ? children : <Navigate to="/login" />;
};
π± Responsive Design with Tailwind
Tailwindβs utility classes used across all components
Dark UI theme
Fully mobile responsive
π Deploying to Vercel
Vercel makes it super easy to deploy Vite + React apps. Hereβs how I did it:
π§ͺ Step-by-Step Guide
Push your project to GitHub
Sign in to vercel.com
Import your GitHub repo
Configure build settings:
Framework:
Vite
Build Command:
npm run build
Output Directory:
dist
Add Environment Variables in Vercel Dashboard:
VITE_TMDB_API_KEY = your_tmdb_api_key
(Also add Firebase keys if needed)
Click Deploy β and you're live π
You can view the deployed project here:
π https://movie-flix-pi-three.vercel.app
π‘ What I Learned
Firebase Auth + React integration
API handling with Axios
Persistent state with localStorage
Context API best practices
TailwindCSS theming and layout
Real-world deployment with Vercel
π Live Demo
π Try it here: https://movie-flix-pi-three.vercel.app/
π¬ Contact Me
πΌ LinkedIn
π¦ X / Twitter
π» GitHub
π§ Chirag Tyagi
Thanks for reading! Iβd love to hear your feedback and suggestions. Feel free to fork the repo and build your own version!
Subscribe to my newsletter
Read articles from Chirag Tyagi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Chirag Tyagi
Chirag Tyagi
Profile Bio Iβm currently pursuing B.Tech in Computer Science and Engineering at Roorkee Institute of Technology, where I am deeply engaged in learning full-stack development with the MERN stack. My passion for technology drives me to explore and stay updated with the latest advancements in the field. Eager to apply and expand my skills, I am committed to continuous learning and growth in the ever-evolving tech landscape.