# Source

Media source state and actions for the player store

Tracks the current media source and readiness.

## Import

```tsx
import { sourceFeature } from '@videojs/react';
```

The `audioFeatures`, `liveAudioFeatures`, `liveVideoFeatures`, and `videoFeatures` [feature bundles](https://videojs.org/docs/framework/react/guides/presets) include this feature.

## API Reference

### State

| Property | Type | Description |
| --- | --- | --- |
| `source` | `string \| null` | Current media source URL (null if none). |
| `canPlay` | `boolean` | Whether enough data is loaded to begin playback. |

### Actions

| Action | Type | Description |
| --- | --- | --- |
| `loadSource` | `(src: string) => string` | Load a new media source. Returns the new source URL. |

### Selector

Pass `selectSource` to [`usePlayer`](https://videojs.org/docs/framework/react/reference/api/use-player) to subscribe to source state. Returns `undefined` if the source feature is not configured.

**SourceInfo.tsx**

```tsx
import { selectSource, usePlayer } from '@videojs/react';

function SourceInfo() {
  const source = usePlayer(selectSource);
  if (!source) return null;

  return <span>{source.source ?? 'No source'}</span>;
}
```

---

React documentation: https://videojs.org/docs/framework/react/llms.txt
All documentation: https://videojs.org/llms.txt
