Movie Trailerz

TMDB API • Typescript • React • Styled Components

A Netflix inspired project showcasing movies and trailers from different genres using the TMDB API.

Movie Trailerz

Overview

Genres are referenced often in different components. To avoid prop-drilling, I wrapped the entire app with genre data using the Context API in React.

The search functionality is also using the Context API but it’s not needed as high in the app architecture as genres. For this reason, it only wraps the components that rely on it, like the Navigation.

The api.ts file has several utility functions to organize various endpoints and functions to execute relevant calls to the API.

For styling, I went with styled components for this build.

To keep things organized, there are three main folders in the src folder — components, context, and pages. The other files — i.e., index.ts, api.ts, etc — are located in the root directory.

API

The TMDB API is the source for all of the data. It has a robust API allowing you to retrieve data with different parameters like genres, trending movies, networks, actors/actresses, credits, and more.

NPM Packages

Packages used to complete this build:

  • Axios
  • React hot toast
  • React icons
  • React modal
  • React paginate
  • React router dom
  • React select
  • React youtube
  • Styled components
  • Swiper

Core Components

Collection of the main components.

Navbar

The Navbar includes links to different pages, a dropdown to select a particular genre, and a global search bar that provides instant results as the user types.

Genre Dropdown

A dropdown to browse and select different movie genres.

nav dropdown showing different movie genres

Search

Instant search as the user types. This is possible with the search endpoint provided by the TMDB API. As the key is pressed, an API call is made to the search endpoint, instantly returning relevant results.

movie search results

Hero

On page load, a random movie from the action genre is selected to be featured in the hero section. There is a button to see more action movies and a button to play the trailer of the currently featured movie.

home hero section showing featured movie

Genre slider

A swipeable carousel to preview movies from different genres. Clicking on a movie in the carousel opens the modal component to autoplay the trailer. The first genre carousel plays automatically.

genre slider to swipe through movies for each genre

Movie Image

A movie card showing the movie poster and rating.

movie card showing rating

Trailer modal

A modal that autoplays a youtube video showing the trailer of a movie. When a user clicks on the "play trailer" button in the hero section on the homepage or when they click on a movie poster, an API call is made to check for the movie trailer. If there is a trailer, the modal component is mounted and a trailer is autoplayed. If there is no movie, a toast message is shown stating a trailer is not available.

move trailer in a modal pop up

Trending Movies

View movies based on trending, top rated, and upcoming. Below is a screenshot of the trending movies page.

trending page which is an example of one of the inner pages

Paginated Movies

The TMDB API returns a page number when a request is made. Each time a user clicks on a page number in the paginated component, that number is used to retrieve results for that specific page.

paginated component showing page ranges

Conclusion

This build was a great reminder on the importance of implementing type checking.

Other Applications

Knowledge Base

Knowledge Base

Firebase • React • Tailwind CSS • Algolia
Algolia Instantsearch

Algolia Instantsearch

Webflow • HTML • CSS • JS • Algolia