---
title: Buffer
description: Buffered and seekable time range state for the player store
---

import FeatureReference from "@/components/docs/api-reference/FeatureReference.astro";
import DocsLink from "@/components/docs/DocsLink.astro";
import FrameworkCase from "@/components/docs/FrameworkCase.astro";

Read-only — tracks buffered and seekable time ranges.

<FeatureReference feature="buffer" />

### Selector

<FrameworkCase frameworks={["react"]}>
Pass `selectBuffer` to <DocsLink slug="reference/use-player">`usePlayer`</DocsLink> to subscribe to buffer state. Returns `undefined` if the buffer feature is not configured.
</FrameworkCase>

<FrameworkCase frameworks={["html"]}>
Pass `selectBuffer` to <DocsLink slug="reference/player-controller">`PlayerController`</DocsLink> to subscribe to buffer state. Returns `undefined` if the buffer feature is not configured.
</FrameworkCase>

<FrameworkCase frameworks={["react"]}>
```tsx title="BufferBar.tsx"
import { selectBuffer, usePlayer } from '@videojs/react';

function BufferBar() {
  const buffer = usePlayer(selectBuffer);
  if (!buffer) return null;

  return (
    <div style={{ width: `${buffer.percentBuffered * 100}%` }} />
  );
}
```
</FrameworkCase>

<FrameworkCase frameworks={["html"]}>
```ts title="buffer-bar.ts"
import { createPlayer, MediaElement, selectBuffer } from '@videojs/html';
import { videoFeatures } from '@videojs/html/video';

const { PlayerController, context } = createPlayer({ features: videoFeatures });

class BufferBar extends MediaElement {
  readonly #buffer = new PlayerController(this, context, selectBuffer);
}
```
</FrameworkCase>
