DEV Community

Arhan Khan
Arhan Khan

Posted on

Build a Movie Watchlist App with JavaScript

Everyone has a list of movies they want to watch, and most of those lists live in a notes app or in someone's head. A watchlist app is a perfect beginner project: search for movies, save them, mark them watched, and rate them — all in the browser.

Use the TMDB API (free API key after signup) to search for movies:

const API_KEY = 'YOUR_TMDB_KEY';

async function searchMovies(query) {
  const res = await fetch(
    `https://api.themoviedb.org/3/search/movie?api_key=${API_KEY}&query=${encodeURIComponent(query)}`
  );
  const data = await res.json();
  return data.results;
}
Enter fullscreen mode Exit fullscreen mode

Each result has a title, release date, poster path, and rating. Build poster URLs with https://image.tmdb.org/t/p/w200 plus the poster path, and fall back to a placeholder when a movie has no poster.

The watchlist itself lives in localStorage, so it survives a page refresh:

const STORAGE_KEY = 'movie-watchlist';

function loadWatchlist() {
  return JSON.parse(localStorage.getItem(STORAGE_KEY)) || [];
}

function saveToWatchlist(movie) {
  const list = loadWatchlist();
  if (list.some((m) => m.id === movie.id)) return; // avoid duplicates
  list.push({ ...movie, watched: false, rating: 0 });
  localStorage.setItem(STORAGE_KEY, JSON.stringify(list));
}
Enter fullscreen mode Exit fullscreen mode

Render the watchlist with three controls per movie: a "watched" toggle, a 1–5 star rating, and a remove button. Add filters at the top — All, To Watch, Watched — and a sort by rating or release date.

This project teaches API calls, state management without a framework, localStorage, and event handling. Once it works, try adding a "watched this month" stats row or a shareable list view that encodes the watchlist in the URL.

Top comments (0)