A Next.js application for tracking movies and TV shows with a global search functionality.
- Global Header: Search input is available on all pages through a shared header component
- Zustand Store: Centralized state management for search functionality and app configuration
- Search Functionality: Real-time search with debouncing and modal results
- Responsive Design: Works on desktop and mobile devices
- Dark Mode Support: Built-in dark mode styling
The header component (components/header.tsx) is included in the root layout (app/layout.tsx) and provides:
- Search input with real-time search
- Clear search functionality
- Focus/blur handling
- Integration with Zustand store
The store (store/useStore.ts) manages:
- Search state (query, results, loading)
- Modal visibility
- Input focus state
- Default page configuration
- Search handlers with debouncing
- User types in the search input
- Input is debounced (400ms delay)
- API call is made to TMDB
- Results are stored in Zustand store
- Modal shows filtered results
- User can click on results to navigate
- Home (
/): Main dashboard with trending movies and filtering tabs - Movie Details (
/movie/[id]): Individual movie/show details - Profile (
/profile): User profile page - Login (
/login): Authentication page - Signup (
/signup): Registration page
- Install dependencies:
npm install- Set up environment variables:
NEXT_PUBLIC_API_KEY=your_tmdb_api_key
NEXT_PUBLIC_TMDB_BASE_URL=https://api.themoviedb.org/3
NEXT_PUBLIC_IMAGE_BASE_URL=https://image.tmdb.org/t/p/w500
# Clerk
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=...
CLERK_SECRET_KEY=...
# InstantDB (server key must NOT be exposed to client)
INSTANTDB_ADMIN_KEY=...- Run the development server:
npm run devThe Zustand store can be configured to set default pages and other app-wide settings:
import { useAppStore } from "@/store/useStore";
const { setDefaultPage, defaultPage } = useAppStore();
// Set default page
setDefaultPage("/movie/123");
// Navigate to default page
navigateToDefault();The search is handled entirely through the Zustand store:
- Debounced API calls (400ms)
- Error handling
- Loading states
- Result filtering
- Modal management
Built with ❤️ by Zamin Mirzad
- Stored in InstantDB via server-side API and mirrored in localStorage for offline UX.
- API:
GET/POST/DELETE /api/bookmarks(uses Clerk auth server-side). - Client: optimistic updates; hydrates on sign-in.