Frontend System Design19 min readPremium

Design Netflix – Frontend System Design

Design Netflix - Frontend System Design
In this guide, we design Netflix from the frontend side: the browse page with its hero and rows, hover previews, the video player, and resume-anywhere playback.

Problem Statement

Build the frontend for a video streaming website like Netflix.

Requirements:

  • After picking a profile, users land on a browse page with a large hero banner and many horizontal rows of titles (e.g., “Trending Now”, “Continue Watching”, “Because You Watched…”)
  • Each row scrolls horizontally, and each tile shows the title’s artwork
  • Hovering or focusing a tile shows a short preview and quick actions (play, add to My List)
  • Clicking play opens a full-screen video player with controls, subtitles, and audio track selection
  • Playback should resume where the user left off, on any device

Describe your approach to component structure, how you would fetch and render the rows, how video playback works in the browser, and any optimizations you’d consider for performance and user experience.


Clarifying Questions

# Question Interviewer’s Answer
1 Which platforms are we designing for: web, mobile apps, or TV? Web (desktop and mobile browsers). TV is out of scope.
2 Where does the catalog and row data come from? Can you describe the API? Please design the API.
3 How many rows and how many titles per row should the browse page support? Assume 30 to 40 rows with up to 50 titles each.
4 Do we need to build the video player, or can we use an existing one? Walk me through how the player works. You can use a library if you explain the trade-offs.
5 Do we need to support adaptive quality (switching between 480p, 1080p, 4K)? Yes, playback should adapt to the user’s network.
6 Is the content protected with DRM? Yes, treat it as premium licensed content.
7 Should hover previews autoplay with sound? Muted autoplay is fine.
8 Do we need to sync playback progress across devices? Yes, “Continue Watching” must be accurate.
9 Are search, profiles management, and downloads in scope? Profiles picker yes, search and downloads are out of scope.
10 Any requirements for accessibility? Yes, subtitles and keyboard support are a must.
11 Should we support localization? Yes, titles, artwork, audio, and subtitles are localized.

Requirements

Functional Requirements

  • Profile picker that scopes all browse data, My List, and progress to the selected profile
  • Browse page with a hero banner and many personalized, horizontally scrollable rows
  • Tile hover/focus preview with muted autoplay and quick actions (play, add to My List, more info)
  • Full-screen video player with play/pause, seek, volume, full screen, subtitles, and audio track selection
  • Adaptive bitrate streaming so quality follows the user’s bandwidth
  • DRM-protected playback
  • Resume playback and an accurate “Continue Watching” row across devices
  • Localized metadata, artwork, audio, and subtitles

Non-Functional Requirements

  • Fast first load of the browse page, even with dozens of rows and hundreds of images
  • Smooth 60fps horizontal scrolling and hover animations
  • Video starts quickly (target under 2 seconds) and rarely rebuffers
  • Scales to millions of concurrent viewers
  • Resilient to flaky networks: the player recovers from dropped segments without the user noticing
  • Accessible (WCAG): captions, keyboard controls, screen reader labels
  • Secure: content is protected, and stream URLs can’t be shared

Napkin Math (Estimations)

Assume a large streaming site, web traffic only:

Metric Estimate / Calculation
Daily Active Users (web) 10,000,000 users/day
Rows per Browse Page 40 rows × 50 titles = 2,000 tiles (only ~6 rows × 6 tiles visible at once)
Artwork per Viewport ~36 tiles + 1 hero ≈ 40 images on first paint
Bitrate per Stream ~5 Mbps for 1080p, ~15 Mbps for 4K
Segment Size 4-second segments at 5 Mbps ≈ 2.5 MB each
Data per Hour of 1080p 5 Mbps × 3,600 s ÷ 8 ≈ 2.25 GB
Progress Heartbeats 1M concurrent viewers ÷ 30 s interval ≈ 33,000 writes/sec

What this tells us: We can never render all 2,000 tiles or load all their images up front, so rows and tiles must be virtualized and lazy-loaded. Video bytes dwarf everything else, so they must come from a CDN, not our API. And progress updates are a high-volume write path, so the client should batch and throttle them.


Architecture / Component Design

Netflix Frontend System Design Architecture

User, Router, and Routing

Everything starts when the user enters the app. React Router handles navigation between the main routes: the profile picker (/profiles), the browse page (/browse), a title details modal (/browse?jbv=:titleId), and the player (/watch/:titleId). The player is a separate route on purpose. It is a heavy, self-contained piece of the app, so we lazy-load it with React.lazy() and only download the player bundle when the user presses play (or prefetch it when they hover a play button).

Keeping the title details as a query parameter on the browse route means the browse page stays mounted underneath the modal. When the user closes it, their scroll position and every row’s horizontal position are exactly where they left them.


SSR vs CSR (Server-Side Rendering vs Client-Side Rendering)

Unlike a public listings site, most of Netflix sits behind a login, so the trade-off looks different here:

  • Logged-out pages (the landing page and public title pages like /title/:id) need SEO and fast first paint, so we server-render them.
  • The browse page is personalized per profile and invisible to search engines. We can still server-render the first few rows to get artwork on screen quickly, and then let the client take over.
  • The player is pure client-side. There is nothing useful to render on the server, since playback depends on browser media APIs.
Page Rendering Why
Landing / public title pages SSR (or static generation) SEO, fast first paint for new visitors
Profile picker CSR Tiny page, behind auth
Browse page SSR for hero + first rows, CSR after Fast Largest Contentful Paint (LCP) on a personalized page
Player CSR, lazy-loaded Depends on browser media APIs, heavy bundle

State Management and Data Flow

There are two very different kinds of state in this app, and it helps to keep them apart:

  • Browse state: the active profile, the list of rows, the titles loaded so far for each row, and My List. This is shared across the browse page and the details modal, so it lives in a global Store (useContext) that the View Model reads and writes.
  • Playback state: current time, buffered ranges, selected quality, subtitles, and whether we’re playing, paused, or buffering. This changes many times per second and only the player cares about it, so it stays local to the player in a usePlayer() hook. Putting it in global context would re-render the whole app on every time update.

The player’s status is best modeled as a small state machine instead of a pile of booleans:


type PlayerStatus =
  | { kind: "idle" }
  | { kind: "loading" }
  | { kind: "playing" }
  | { kind: "paused" }
  | { kind: "buffering" }
  | { kind: "ended" }
  | { kind: "error"; code: string; retryable: boolean };

This makes impossible combinations (like “playing” and “error” at the same time) impossible to represent, and every control can render off a single value.

Option Pros Cons Best Use Case
useState / useReducer Built-in, fast, local Not shared across routes Player state, row scroll position
useContext Global, minimal boilerplate Re-renders consumers on every change Profile, rows, My List
Redux / Zustand Fine-grained subscriptions, devtools Extra dependency and boilerplate If the browse state grows (search, notifications, downloads)
React Query / SWR Caching, deduping, background refetch Another dependency Server data like rows and title details

Overall, go with useContext for browse state and local state for the player. If you split the context into small providers (profile, rows, My List), you avoid most of the re-render cost that people worry about with Context.


Browse Page Component Structure

The BrowseContainer is the browse page’s main “container” component. It calls useViewModel() to get the rows for the current profile. Inside, it renders a BrowseView, which shows the HeroBanner and a vertically virtualized RowList. Each Row is a horizontally virtualized list of TitleCard tiles.

The component structure looks like:


<BrowseContainer>
  <BrowseView>
    <HeroBanner />
    <RowList>
      <Row>
        <TitleCard>
          <PreviewPlayer />
        </TitleCard>
      </Row>
    </RowList>
  </BrowseView>
</BrowseContainer>

BrowseContainer

This is the “smart” container at the top of the browse page. It calls useViewModel() to get the row list, loading status, and the active profile, and it triggers fetching the next batch of rows as the user scrolls down. It doesn’t know anything about layout.

BrowseView

This view handles conditional rendering: a skeleton of grey rows while the first response loads, an error state with a retry button if it fails, and otherwise the hero banner and rows.

HeroBanner

The large featured title at the top. It’s usually the Largest Contentful Paint element, so its image is preloaded and gets fetchpriority="high". After a short delay, it can swap the still image for a muted trailer.

RowList

Renders the rows vertically. With 40 rows, we only render the rows in or near the viewport, and we only fetch a row’s titles when it is about to scroll into view (using IntersectionObserver with a generous rootMargin).

Row

One horizontal row, like “Trending Now”. It owns its own horizontal scroll position (local state) and virtualizes its tiles, so a 50-title row only mounts the 6 to 10 tiles you can see plus a small buffer. Arrow buttons page by one viewport of tiles at a time.

TitleCard

One tile. It shows the artwork, and on hover or keyboard focus it expands into a preview card with the title, maturity rating, and quick actions. It waits a short moment (around 300 to 500ms) before starting the preview so that a mouse sweeping across a row doesn’t fire off dozens of video requests.

PreviewPlayer

A lightweight, muted, low-bitrate video used only for hover previews and the hero. It’s separate from the full player so the browse page never loads the full player, DRM, or subtitle code.

Component Relationship Table

Component Responsibility Receives Data From Passes Data To
BrowseContainer Fetches rows, coordinates data View Model BrowseView
BrowseView Loading, error, and content states BrowseContainer HeroBanner, RowList
HeroBanner Featured title, trailer BrowseView PreviewPlayer
RowList Vertical virtualization, lazy row fetch BrowseView Row
Row Horizontal scroll and virtualization RowList TitleCard
TitleCard Artwork, hover preview, quick actions Row PreviewPlayer

Player Component Structure

The player lives on its own route and has its own container:


<PlayerContainer>
  usePlayer() // playback logic
  <VideoPlayer />
  <PlayerControls>
    <SeekBar />
    <VolumeControl />
    <SubtitleAudioMenu />
    <NextEpisodeButton />
  </PlayerControls>
  <SubtitleOverlay />
</PlayerContainer>
  • PlayerContainer calls usePlayer(), which owns the streaming engine, the player state machine, and the progress heartbeat.
  • VideoPlayer wraps the native <video> element. All the hard work (fetching segments, switching quality, DRM) happens in the streaming engine, which feeds bytes into this element.
  • PlayerControls auto-hide after a few seconds of no mouse movement and reappear on any input.
  • SubtitleOverlay renders subtitles ourselves instead of relying on native <track> rendering, so we can control styling (size, background, position) consistently across browsers.

How Video Playback Works in the Browser

This is the part interviewers love to dig into. You can’t just set <video src="movie.mp4"> for a two-hour 4K movie. The file is huge, the quality can’t adapt to the network, and it can’t be protected. Instead, streaming sites use adaptive bitrate streaming.

Progressive download is the native <video src> path. The browser fetches with byte ranges, can pause the download, and does not need your JS. It cannot switch quality mid-play, cannot encrypt with EME the way a streaming service needs, and a two-hour 4K file is a bad seek. Mention it so they know you know the tag. Then move to HLS/DASH.

The container is not the codec. “MP4” or “WebM” does not mean it plays. You check canPlayType on the full MIME + codec string, plus the DRM key system. Capability-driven, not “we only ship mp4.”

Discovery and the player should be one SPA. Netflix and YouTube persist browse data across the watch route so back is instant and you can prefetch the next title’s manifest. An MPA watch page throws that cache away.

Subtitles vs captions. Subtitles are dialogue for people who can hear but need the language. Captions include speaker names, music, and sound effects for people who cannot hear. You render both from WebVTT (or IMSC) as an overlay you style. Do not ship one English track and call it done.

i18n. Localize title metadata, controls, dates, and ratings. Persist audio and subtitle language, then fall back to what the title actually has. Test RTL chrome and subtitle placement. Do not hide a title because it lacks an exact audio match for the UI locale.

Adaptive Bitrate Streaming (HLS and DASH)

Each title is encoded on the server into several quality levels (renditions), for example 240p, 480p, 720p, 1080p, and 4K. Each rendition is cut into small segments of a few seconds each. A manifest file lists every rendition and where its segments live.

  • DASH (Dynamic Adaptive Streaming over HTTP) uses an XML manifest (.mpd). It’s codec-agnostic and widely used on the web.
  • HLS (HTTP Live Streaming) uses a playlist (.m3u8). It’s Apple’s format and plays natively in Safari.
Rendition Approx. Bitrate When the Player Picks It
480p ~1 Mbps Startup on unknown networks, weak mobile connections
720p ~3 Mbps Average connections
1080p ~5 Mbps Good broadband
4K ~15 Mbps Fast broadband, 4K display, premium plan

Media Source Extensions (MSE)

Media Source Extensions is the browser API that makes this possible. Instead of giving the <video> element a file, we give it a MediaSource object and append segments to it ourselves:


const video = document.querySelector("video")!;
const mediaSource = new MediaSource();
video.src = URL.createObjectURL(mediaSource);

mediaSource.addEventListener("sourceopen", async () => {
  const sourceBuffer = mediaSource.addSourceBuffer('video/mp4; codecs="avc1.640028"');

  // The streaming engine decides which rendition to fetch next.
  const segment = await fetch(nextSegmentUrl()).then((r) => r.arrayBuffer());
  sourceBuffer.appendBuffer(segment);
});

Because our code fetches every segment, it can pick a different quality for the next segment at any time. That’s what makes the quality switch seamless. On iPhone, Safari only added a version of MSE (Managed Media Source) in iOS 17.1, so for older iPhones we fall back to native HLS playback.

Choosing the Quality (ABR Logic)

The ABR (Adaptive Bitrate) algorithm decides which rendition to download next. There are two common signals:

  • Throughput-based: measure how fast recent segments downloaded and pick the highest bitrate safely below that (with a safety margin, e.g., 80% of measured bandwidth).
  • Buffer-based: look at how many seconds of video are already buffered. With a healthy buffer (e.g., 30 seconds), we can afford a higher bitrate. With an almost empty buffer, we drop quality to avoid a rebuffer.

Production players combine both. At startup, they pick a low rendition so the first frame shows quickly, then climb as the buffer fills. Rebuffering annoys users far more than a few seconds of lower quality, so the algorithm should be quick to step down and slow to step up.

DRM with Encrypted Media Extensions (EME)

Licensed content is encrypted. The browser decrypts it using Encrypted Media Extensions (EME) and a Content Decryption Module (CDM) built into the browser:

  • Widevine on Chrome, Firefox, Edge, and Android
  • PlayReady on Edge and Windows
  • FairPlay on Safari

The flow: the player hits encrypted content, the browser emits an encrypted event, the player requests a license from our license server (with the user’s auth token), and the CDM uses that license to decrypt frames. Decrypted frames never reach our JavaScript, which is the point. Higher resolutions like 4K usually require hardware-backed DRM, which is why some browsers are capped at lower quality.

Libraries vs Custom Implementation

  • Using a library:
    Shaka Player (DASH and HLS, strong DRM support), hls.js (HLS over MSE), dash.js (the DASH reference player), and Video.js (a UI layer on top of these).

    • Pros: Years of edge cases handled (codec quirks, DRM differences, segment errors), solid ABR out of the box.
    • Cons: Larger bundle, and less control over ABR and buffering if you need to tune them for your network patterns.
  • Custom build:
    Netflix-scale companies build their own engines so they can tune ABR, preloading, and telemetry precisely.

    • Pros: Full control, smallest bundle for your exact needs.
    • Cons: Months of work and a long tail of browser bugs.

In an interview, the strong answer is: use Shaka Player or hls.js for the streaming engine, wrap it behind your own usePlayer() hook, and build your own controls UI. That way you could swap the engine later without touching the UI.

Building the Player (the part after you pick a library)

Netflix player loop: manifest, ABR, fetch, appendBuffer, seek flush
Naming Shaka is not the answer. The interviewer wants the loop that turns a manifest into frames, and the state machine that decides what to fetch next.

Two SourceBuffers, not one. Video and audio are separate renditions. A 1080p video track can sit next to a 128 kbps audio track. You append them independently and they share a timeline on the same MediaSource. If you mux them yourself you cannot change video quality without re-downloading audio.


type PlayerState =
  | "idle"
  | "loading"      // waiting for first frame
  | "playing"
  | "paused"
  | "stalled"      // buffer ran dry
  | "seeking"
  | "ended"
  | "error";

type Engine = {
  mediaSource: MediaSource;
  video: SourceBuffer;   // video/mp4; codecs="avc1.640028"
  audio: SourceBuffer;   // audio/mp4; codecs="mp4a.40.2"
  manifest: Manifest;
  playhead: number;
  bufferEnd: number;
  rendition: Rendition;
};

The load loop (runs whenever bufferEnd - playhead < TARGET, usually 20–30s):

  1. Pick a rendition (ABR). At startup pick the lowest so the first frame is fast, then climb.
  2. Find the segment that covers bufferEnd (binary search the playlist by start time).
  3. Fetch it from the CDN. On 404 / timeout, retry once, then drop a rendition.
  4. Wait until !sourceBuffer.updating, then appendBuffer. A QuotaExceededError means you have to evict.
  5. Evict from the front: sourceBuffer.remove(0, playhead - 30) so you keep ~30s behind the playhead for a short rewind, not the whole title.

Never append from two fetches at once onto the same SourceBuffer. Queue them. updating is the lock.

Seek is a flush, not a currentTime = and a prayer.

  1. Set state seeking. Pause appends.
  2. sourceBuffer.remove(0, Infinity) (or abort the current append, then remove).
  3. Find the keyframe at or before the target time. You cannot start a segment mid-GOP. HLS/DASH segment boundaries are already keyframes if the packager is honest — say that.
  4. Fetch that segment (and the matching audio segment). Append. Set video.currentTime = target.
  5. Show the last displayed frame (or a placeholder) until seeked. Then resume the load loop from the new playhead.

A naive seek that leaves old segments in the buffer will decode garbage or stall. Always flush.

Stall recovery. waiting fires when the pipeline runs dry. Drop to the lowest rendition, fetch the next segment immediately, and do not climb again until bufferEnd - playhead > 10s. Count stalls. Two stalls in 30s is a signal to stay down. This is more important than the pretty ABR formula.

Custom chrome on top of a naked <video>. Hide native controls (controls={false}). You own:

  • Play/pause, skip ±10s, next episode
  • Seek bar that reads currentTime from a ref on rAF / 250ms, not from React state
  • Buffered ranges from video.buffered painted as a second bar
  • Volume / mute, fullscreen (video.requestFullscreen() or the container), Picture-in-Picture
  • Subtitle overlay you render yourself (WebVTT parsed into cues, positioned at the bottom-safe area). Native <track> styling is inconsistent and you cannot theme it.
  • Auto-hide the chrome after ~3s of no pointermove; show on any key or pointer. Keyboard: Space, J/K/L, arrows, F, M, C (captions), 0–9 (percent seek).

The <video> is a decoder and a frame sink. It is not the product. If you leave native controls on, you cannot put Next Episode, skip-intro, or a title card on the same surface.

Audio description / secondary audio is a different audio rendition, not a gain node. Switching it is a SourceBuffer swap: remove the current audio buffer, append the new rendition from the playhead’s keyframe. Same as a video quality switch.

iOS. Managed Media Source is iOS 17.1+. Older iPhones get a native <video src="master.m3u8"> and you lose ABR control. Feature-detect and keep one UI.


API Design

The API uses RESTful design principles over HTTPS. All API endpoints return JSON. Video segments are not served by this API. They come from a CDN through the manifest URL the playback endpoint returns.

Authentication & Headers

The session lives in an httpOnly, Secure cookie, so JavaScript can’t read it. Every browse and playback request is scoped to a profile.

  • Cookie: session cookie (httpOnly, Secure, SameSite)
  • X-Profile-Id: the active profile, e.g., p_123
  • Accept-Language: e.g., en-US for localized titles and artwork

Pagination: Page-Based vs Cursor-Based

  • Page-Based: Uses page numbers (page=2&pageSize=10). Simple, but if the personalized list changes between requests, the user can see duplicates or miss titles.
  • Cursor-Based: Uses an opaque cursor (cursor=abc123) that remembers where the last batch ended.

For Netflix, cursor-based pagination is the better fit, both for loading more rows down the page and for loading more titles within a row. Personalized rows are generated per profile and can change while the user is browsing, and cursors avoid duplicates when that happens.

API Endpoint Design & Client Data Model

Here are the core endpoints as TypeScript response types. You can also use these as the client data model for your Store.


// --- Shared Types ---

export type Artwork = {
  url: string;          // CDN URL, already sized for the requested width
  width: number;
  height: number;
  blurHash?: string;    // tiny placeholder shown while the image loads
};

export type TitleSummary = {
  id: string;
  name: string;
  artwork: Artwork;
  maturityRating: string;        // e.g., "TV-MA"
  previewUrl?: string;           // short, low-bitrate, unencrypted preview
  progress?: { positionSec: number; durationSec: number };
};

export type Row = {
  id: string;
  title: string;                 // e.g., "Trending Now"
  titles: TitleSummary[];        // first batch only
  nextCursor: string | null;
};

// --- API: Browse Page ---
// GET /api/browse?cursor=<cursor>&limit=10
export type GetBrowseResponse = {
  hero: TitleSummary;
  rows: Row[];
  nextCursor: string | null;     // more rows further down the page
};

// --- API: More Titles in a Row ---
// GET /api/rows/:rowId/titles?cursor=<cursor>&limit=20
export type GetRowTitlesResponse = {
  titles: TitleSummary[];
  nextCursor: string | null;
};

// --- API: Title Details (details modal) ---
// GET /api/titles/:id
export type GetTitleDetailResponse = TitleSummary & {
  synopsis: string;
  year: number;
  cast: string[];
  episodes?: { id: string; season: number; number: number; name: string }[];
};

// --- API: Start Playback ---
// POST /api/playback/:titleId
export type StartPlaybackResponse = {
  sessionId: string;
  manifestUrl: string;           // signed, short-lived CDN URL
  licenseUrl: string;            // DRM license server
  resumePositionSec: number;
  subtitles: { language: string; url: string }[];
  audioTracks: { language: string; id: string }[];
};

// --- API: Save Progress ---
// PUT /api/progress/:titleId
export type SaveProgressRequest = {
  sessionId: string;
  positionSec: number;
  updatedAt: number;             // client timestamp, newest write wins
};

// --- API: My List ---
// PUT /api/my-list/:titleId   (add)
// DELETE /api/my-list/:titleId (remove)

// --- Error Response (all endpoints) ---
export type ErrorResponse = {
  error: string;
  message: string;
  status: number;
};

Explanation

  • GET /api/browse: Returns the hero and the first batch of rows, each with its first batch of titles. The client asks for more rows with nextCursor as the user scrolls down.
  • GET /api/rows/:rowId/titles: Loads more titles when the user scrolls a row to the right.
  • POST /api/playback/:titleId: Starts a playback session. It checks the user’s plan and concurrent stream limit, then returns a signed manifest URL, the license URL, and the resume position. It’s a POST because it creates a session on the server.
  • PUT /api/progress/:titleId: Saves the playback position. PUT is idempotent, so retries are safe, and updatedAt lets the server ignore an older write that arrives late.
  • Error responses: All errors return a JSON object with an error string, a human-readable message, and a status code.

Continue Watching and Progress Sync

“Continue Watching” is only as good as the progress data behind it. From the napkin math, a heartbeat for every viewer is tens of thousands of writes per second, so the client has to be smart about it:

  • Throttle: send progress every 30 seconds while playing, not on every timeupdate event (which fires several times per second).
  • Send on important moments: pause, seek, episode end, and when the user leaves the player.
  • Survive tab closes: on pagehide or when visibilitychange reports hidden, use navigator.sendBeacon() (or fetch with keepalive: true), which the browser delivers even as the page unloads.
  • Last write wins: include updatedAt so a slow request from an old session can’t overwrite a newer position from another device.
  • Optimistic UI: update the “Continue Watching” row in the Store as soon as the user exits the player, without waiting for the server.

Optimizations: Fast Start, Smooth Scrolling, and More

Fast Video Start

  • Prefetch on intent: when the user hovers the play button or opens the details modal, prefetch the player bundle and call the playback endpoint in the background.
  • Start low, climb fast: begin with a lower rendition so the first frame appears quickly, then let ABR step up.
  • Preconnect to the CDN: a <link rel="preconnect"> to the video CDN removes DNS and TLS setup time from the critical path.
  • Acquire the DRM license early: request the license in parallel with the first segments instead of waiting for the encrypted event.

Browse Page Performance

  • Virtualize in both directions: only rows near the viewport are mounted, and only visible tiles within each row.
  • Lazy-load artwork: loading="lazy" for off-screen tiles, fetchpriority="high" for the hero.
  • Responsive images: request artwork sized for the tile through srcset, in AVIF or WebP with a JPEG fallback.
  • Placeholders: fixed aspect ratio boxes with a blurred placeholder, so tiles never shift the layout (good for Cumulative Layout Shift).
  • Animate cheaply: hover expansion uses transform: scale() and opacity, which the browser can composite on the GPU without re-layout.
  • Debounce previews: wait before starting a hover preview, cancel the request if the user moves on, and keep only one preview playing at a time.

Graceful Loading States

  • Skeleton rows on first load, sized like real rows
  • A row that fails to load shows a small inline retry instead of breaking the page
  • A spinner over the video only after a short delay while buffering, so short stalls don’t flash a spinner

Error Handling and Smart Retry Logic

  • Segment failures: retry with exponential backoff, and if a rendition keeps failing, drop to a lower one or switch to a backup CDN listed in the manifest.
  • Expired URLs: if a signed manifest or segment URL returns 403, request a fresh playback session and resume from the current position.
  • Stream limits: if the server rejects playback because too many devices are streaming, show a clear message instead of a generic error.
  • Network drop: pause gracefully when the buffer runs out, and resume automatically when the online event fires.

Other Key Optimizations

  • Code splitting: separate bundles for browse, details modal, and player
  • Caching: cache browse rows in memory, so going back from the player is instant, and refresh them in the background
  • Telemetry: track startup time, rebuffer rate, and average bitrate per session. These are the metrics that tell you whether playback is healthy.

Accessibility and Security

Accessibility (a11y)

  • Subtitles and captions: WebVTT subtitles in every available language, with user settings for size, color, and background
  • Audio description: expose audio description tracks in the audio menu
  • Keyboard controls: space to play/pause, arrow keys to seek and change volume, F for full screen, M to mute. Every control is a real <button> with an aria-label.
  • Rows: each row is a labeled region (e.g., aria-label="Trending Now"), arrow buttons are keyboard accessible, and keyboard focus on a tile shows the same preview as hover
  • Reduced motion: respect prefers-reduced-motion by turning off autoplaying previews and hover animations
  • Focus management: trap focus inside the details modal, and return focus to the tile that opened it on close

Security

  • DRM: premium content is encrypted and decrypted only inside the browser’s CDM through EME
  • Signed, short-lived URLs: manifest and segment URLs expire, so sharing a link doesn’t share the stream
  • Server-side entitlements: plan limits (like 4K or the number of concurrent streams) are enforced by the playback endpoint, never just hidden in the UI
  • Session security: httpOnly, Secure, SameSite cookies protect against token theft through XSS and against CSRF
  • XSS prevention: escape all title metadata, and use a Content Security Policy (CSP)
  • HTTPS everywhere: EME requires a secure context anyway

Conclusion: How to Design Netflix

Netflix looks like a simple grid of posters, but the frontend is really two apps: a browse page that has to render thousands of tiles smoothly, and a video player that has to start fast and never stall. Keep them separate (different routes, bundles, and state), virtualize everything on the browse page, and lean on adaptive bitrate streaming with MSE and EME for playback. If you can explain how a segment gets from the CDN into the <video> element, and how the player decides which quality to fetch next, you’ll stand out in this interview.