- Node.js (v18+ recommended)
- npm (v9+ recommended)
- Clone the repository
- Install dependencies:
npm install
- Initialize Vite Project with React + TypeScript
- Install Required Dependencies
- Setup Redux Store
- Wrap app with the Redux
Providerinsrc/main.tsx
- Setup React Router inside
App.tsx - Configure SCSS under
styles/main.scssas global SCSS file
- Install Axios for fetching API data
- Add interfaces under
types/index.tsx:Filminterface- Films interface for API response (for 3 categories)
- Add films slice under store:
- Fetch data from API
- Save response in Redux state
- Create:
appClientfile undersrc/services(reusable axios instance)filmAPIfor API calls in Redux slice
- Customize film slice to handle different categories for carousel
- Dynamic & reusable for different pages
Implementation Steps:
- Create basic structure:
- Category title
- Films array (using defined interface)
- Create
FilmCardcomponent (used in carousel map loop):- Shows: title, image, short description
- Click to view more details
- Add SCSS files for both components
- DRY Code:
- Reusable
CarouselandFilmCardcomponents
- Reusable
- Dynamic rendering:
- Use
categories arrayto map through categories - Avoid repetitive code
- Use
- Add Navigation Arrows:
- Horizontal scroll functionality
- State handler + styling
- Add loading skeletons during data fetch
- For film card and details (shown during loading)
- Contains 2 buttons:
- Back to home
- Go to wishlist
- Shows buttons conditionally based on current page
- Shows:
- Header title
- Navigator component
- Carousel/FilmCards for each category
- Uses different endpoint URLs for each category
-
Page Structure:
- Shows clicked film's details
- New Redux state for clicked film details
- Styled components
- Loading skeleton during fetch
-
Features:
- Genre utils function (finds first film category by ID for styling)
- Film details includes:
- Image, title, overview
- Wishlist button
- Extra info: release date, rating, status, tagline, adults
-
Wishlist Functionality:
- Handle add/remove from wishlist
- Redux slice with add/remove functions
- Persist to localStorage
- Navigation and toast notifications
- Displays film cards from wishlist
- Redux state + localStorage persistence
- Maintains data until user removes from UI
Install the required Express.js package and its TypeScript types.
Create a new server entry file that will:
- Handle SSR rendering using ReactDOM's
renderToString - Wrap your application with Redux Provider and StaticRouter
- Capture the initial Redux state
Configure an Express server that will:
- Integrate with Vite's middleware
- Serve your SSR-rendered application
- Inject the preloaded Redux state into the HTML template
Modify your existing client entry to:
- Hydrate the app instead of rendering from scratch
- Pick up the server-injected Redux state
- Initialize the store with the preloaded state
Update your main HTML file to include:
- Placeholder for SSR-rendered content
- Slot for preloaded state injection
Add new scripts to package.json for:
- Building both client and server bundles
- Previewing the SSR application