Skip to main content

Get Started in 5 Minutes

This quick start guide will have ReactFlix running on your local machine with minimal setup. Perfect for developers who want to dive right in.
Prerequisites: Ensure you have Node.js (v14+) and npm installed. Check with node --version and npm --version.

Quick Installation

1

Clone the Repository

Clone the ReactFlix repository to your local machine:
git clone <repository-url>
cd streaming
2

Install Dependencies

Install all required npm packages:
npm install
This installs:
  • React 19.2.4 and React DOM
  • React Router DOM 7.13.1
  • React Scripts 5.0.1
  • Testing libraries
3

Start Development Server

Launch the application in development mode:
npm start
The app will automatically open at http://localhost:3000
The development server supports hot reloading - changes you make to the code will automatically refresh the browser!

Verify Installation

Once the development server starts, you should see:
  1. Homepage - Welcome message and featured movies section
  2. Navigation - Header with links to Movies, Rentals, and Purchases
  3. Movie Grid - 4 featured movies with poster images
  4. Interactive Elements - Hover effects and clickable movie cards

Explore the Application

Browse Movies

Navigate to the full catalog:
http://localhost:3000/peliculas
Try the search and filter features:
  • Search for “Matrix” or “Nolan”
  • Filter by genre: Science Fiction, Action, Drama, Crime
  • View movie details by clicking on any card

View Movie Details

Click on any movie to see:
  • Full synopsis and cast information
  • Movie ratings and duration
  • Embedded trailer player
  • Rental and purchase options

Test Rental & Purchase

1

Select a Movie

Navigate to any movie detail page
2

Choose Action

Click either “Alquilar” (Rent) or “Comprar” (Purchase)
3

View Library

Access your rentals at /gestion-alquileres or purchases at /gestion-compras
4

Manage Rentals

On the rentals page, you can extend rental periods by 48 hours

Understanding the Code

Main Application Component

The app is structured with React Router for navigation:
src/App.js
import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Header from './components/Header';
import Footer from './components/Footer';
import PrincipalPage from './pages/PrincipalPage';
import PeliculasPage from './pages/PeliculasPage';
import PeliculaDetailPage from './pages/PeliculaDetailPage';
import AlquileresPage from './pages/AlquileresPage';
import ComprasPage from './pages/ComprasPage';

function App() {
  return (
    <Router>
      <div className="app">
        <Header />
        <main className="app__main">
          <Routes>
            <Route path="/" element={<PrincipalPage />} />
            <Route path="/peliculas" element={<PeliculasPage />} />
            <Route path="/pelicula/:id" element={<PeliculaDetailPage />} />
            <Route path="/gestion-alquileres" element={<AlquileresPage />} />
            <Route path="/gestion-compras" element={<ComprasPage />} />
          </Routes>
        </main>
        <Footer />
      </div>
    </Router>
  );
}

export default App;

Custom Search Hook

The application uses a custom hook for search and filtering:
src/hooks/usePeliculaSearch.js
import { useState, useEffect } from "react";
import { mockPeliculas } from "../data/mockPeliculas";

const usePeliculaSearch = (initialPeliculas = mockPeliculas) => {
  const [searchTerm, setSearchTerm] = useState("");
  const [selectedCategory, setSelectedCategory] = useState("");
  const [filteredPeliculas, setFilteredPeliculas] = useState(initialPeliculas);
  const [loading, setLoading] = useState(false);

  // Filter movies by search term and category
  useEffect(() => {
    setLoading(true);

    const timer = setTimeout(() => {
      let results = mockPeliculas;

      // Search by title, director, or cast
      if (searchTerm) {
        results = results.filter(
          (pelicula) =>
            pelicula.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
            pelicula.director.toLowerCase().includes(searchTerm.toLowerCase()) ||
            pelicula.cast.some((actor) =>
              actor.toLowerCase().includes(searchTerm.toLowerCase())
            )
        );
      }

      // Filter by genre
      if (selectedCategory) {
        results = results.filter(
          (pelicula) => pelicula.genre === selectedCategory
        );
      }

      setFilteredPeliculas(results);
      setLoading(false);
    }, 300);

    return () => clearTimeout(timer);
  }, [searchTerm, selectedCategory]);

  return {
    searchTerm,
    setSearchTerm,
    selectedCategory,
    setSelectedCategory,
    filteredPeliculas,
    loading,
    categories: [...new Set(mockPeliculas.map((p) => p.genre))]
  };
};

export default usePeliculaSearch;

Available Routes

RouteComponentDescription
/PrincipalPageHomepage with featured movies
/peliculasPeliculasPageFull catalog with search/filter
/pelicula/:idPeliculaDetailPageIndividual movie details
/gestion-alquileresAlquileresPageManage rented movies
/gestion-comprasComprasPageManage purchased movies

Development Commands

npm start
# Opens http://localhost:3000
# Hot reload enabled

Data Storage

ReactFlix uses browser LocalStorage to persist user data:
// Rentals stored in localStorage
localStorage.setItem('alquileres', JSON.stringify(rentedMovies));
const alquileres = JSON.parse(localStorage.getItem('alquileres') || '[]');

// Purchases stored in localStorage
localStorage.setItem('compras', JSON.stringify(purchasedMovies));
const compras = JSON.parse(localStorage.getItem('compras') || '[]');
LocalStorage data is browser-specific and will be lost if you clear browser data. For production, consider implementing backend storage.

Next Steps

Installation Guide

Learn about detailed setup, prerequisites, and configuration options

Component Reference

Explore all available components and their props

Customization

Customize ReactFlix with your own branding and features

Data Management

Learn how to manage movie data and integrate APIs

Troubleshooting

Port Already in Use

If port 3000 is already in use:
# On macOS/Linux
lsof -ti:3000 | xargs kill -9

# Or set a different port
PORT=3001 npm start

Module Not Found

If you encounter module errors:
# Clear node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

White Screen on Start

Check the browser console for errors and ensure:
  • All dependencies are installed
  • You’re using Node.js v14 or higher
  • No syntax errors in recent code changes
Need help? Check the browser console (F12) for detailed error messages.

Build docs developers (and LLMs) love