Stop 09 · React Hooks, Routing & StylingProjects · 1/1

Movie Search App

Part of the MERN Stack Roadmap

In short

A movie app is the perfect practice ground: a real API with images, search, filters and detail pages. It's also a project that looks good in your portfolio screenshots.

Build a movie search app with React Router pages, a debounced search box, a data-fetching custom hook, loading and error states and Tailwind styling.

The jaadu holds popcorn and looks up at a board of colourful picture-only movie posters.

Think of it like this

The single-screen theatre noticeboard

Outside the old theatre, a board lists what's showing, the timings and posters. You read it, pick a film and step inside for details. Your app is that board, but with every movie ever made and a search box.

Watch it happen

Search to poster grid

Movie app
TMDB API
Image CDN

GET /search/movie

1/5After the debounce, the app searches with query=dangal and your API key.

The big ideas

What you need to know

Debounced search

Search titles as the user types, without firing a request on every key.

Filter and sort

Filter by genre and year, sort by rating or release date, all through query params.

Detail pages

Clicking a movie opens /movie/:id with the cast, runtime and trailer.

API keys

TMDB and OMDb need a key. Keep it in a .env file and out of your Git repo.

How it works

Build plan

  1. 1

    Get an API key

    Sign up on TMDB or OMDb and store the key in .env.

  2. 2

    Trending page

    Show a grid of posters with skeletons while loading.

  3. 3

    Search

    Add a debounced search box with 'No results' handling.

  4. 4

    Details and filters

    Add a movie detail route, then genre filters and pagination.

See it in code

Walk through the code

ts
1const KEY = import.meta.env.VITE_TMDB_KEY;2const IMG = "https://image.tmdb.org/t/p/w342";3 4export async function searchMovies(q: string, page = 1) {5  const params = new URLSearchParams({ api_key: KEY, query: q, page: String(page) });6  const res = await fetch(`https://api.themoviedb.org/3/search/movie?${params}`);7  if (!res.ok) throw new Error("Search failed");8  return res.json(); // { page, results, total_pages }9}10 11const posterUrl = (path: string | null) => (path ? IMG + path : "/no-poster.png");

1/4The key comes from .env, and IMG is the base for poster URLs.

TMDB returns only a poster path, so you build the full image URL yourself. Some movies have no poster, so keep a fallback ready.

Save yourself the pain

Common mistakes

Oops

Committing your API key to a public GitHub repo.

Do this instead

Put it in .env, add .env to .gitignore, and share a .env.example with an empty value.

Oops

Assuming every movie has a poster, rating and overview.

Do this instead

Many fields can be null. Show a placeholder image and 'No description yet'.

Your mission

Milestone 1: search and posters

~45 min

Quick check

Your Vite app reads the TMDB key from import.meta.env. Can users still see the key?

Go deeper

  1. 1Add a details page at /movie/:id that fetches one movie.
  2. 2Keep the search term in the URL query string so results can be shared.
  3. 3Deploy it and add the live link to your GitHub README.

Also part of these roadmaps

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge