A minimal Netflix-style movie browser powered by TMDB. Built with Next.js (App Router), TypeScript and Tailwind CSS.
-
Put your TMDB API Read Access Token (the long
eyJ…token, not the short v3 API key) in.env.local:TMDB_API_KEY=eyJhbGciOi...api_TMDB=...also works for compatibility, but preferTMDB_API_KEY. Never prefix it withNEXT_PUBLIC_. On Vercel, add the same variable under Project → Settings → Environment Variables. -
Run it:
npm install npm run dev # http://localhost:3000 npm run build && npm start
app/
page.tsx home: featured hero, continue watching, movie + show rows
movies/, tv/ section pages (rows + genre bar)
genres/ all movie and TV genres
browse/[kind]/[id]/[[...page]]/ genre grid with numbered pagination (/browse/tv/18/3)
movie/[id]/ movie detail
tv/[id]/[[...season]]/ show detail with season tabs + episodes (/tv/1399/2)
search/ movies + shows, filter tabs, pagination (client -> /api/q)
api/q/route.ts search endpoint (rate limited, trimmed JSON)
watch/[...slug]/route.ts resolves the playback source server-side and redirects the player
components/ UI (Player.tsx = player overlay, prev/next episode, resume)
lib/
tmdb.ts server-only data client (Bearer auth, retry, caching, trimming)
media.ts server-only playback source (change provider here)
history.ts "continue watching" — browser localStorage only
paths.ts, images.ts, types.ts, format.ts
next.config.ts /img/* image proxy rewrite, redirects
- Every TMDB request lives in
lib/tmdb.ts, which starts withimport "server-only". The build fails if a client component imports it. - The token is read from
process.envat request time and sent as anAuthorization: Bearerheader. It never goes in a URL and is never bundled. - Pages are Server Components. The only data request the browser makes is
GET /api/searchon our own domain. It returns trimmed fields (id, title, posterPath, year, rating), not raw TMDB responses. /api/searchallows 40 requests per minute per IP and rejects queries over 100 characters. Upstream errors return a generic message.productionBrowserSourceMaps: falseandpoweredByHeader: falseare set innext.config.ts.
Honest caveats
- Any JavaScript sent to the browser can be downloaded and read, even without source maps. What stays secret is what never leaves the server: the token, the TMDB endpoints and query shaping, and
lib/*. - Poster images load directly from TMDB's public CDN,
image.tmdb.org. That's expected, because those URLs aren't secret. A visitor can tell the images come from TMDB, but can't see the API or the key. - The rate limiter keeps its counts in memory, and each Vercel serverless instance has its own memory. It slows down casual abuse but isn't a global limit. For a hard limit, add a Vercel Firewall rate-limit rule or a Redis-backed limiter such as Upstash.
The playback source is built in lib/media.ts. The page only has /watch/movie/:id or /watch/tv/:id/:season/:episode links, and the server redirects those to the provider.