Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@page-speed/video

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@page-speed/video

Performance-optimized React Video component with HLS streaming support. Drop-in video implementation of web.dev best practices with zero configuration.

latest
Source
npmnpm
Version
0.0.7
Version published
Maintainers
2
Created
Source

@page-speed/video

Performance-optimized React Video component with HLS streaming support. Drop-in video implementation of web.dev best practices with zero configuration.

Features

  • HLS Streaming: Automatic adaptive bitrate streaming with hls.js
  • Native HLS: Safari/iOS use native HLS support (no extra dependencies)
  • Progressive Fallback: MP4 fallback for unsupported browsers
  • Transform API: Automatic video transformation to HLS
  • Poster Optimization: OptixFlow integration for optimized poster images
  • Processing Strategies: Optimistic or polling for video processing
  • Tree-shakeable: Import only what you need
  • TypeScript: Full type safety
  • Zero Config: Works out of the box with sensible defaults

Installation

npm install @page-speed/video
# or
pnpm add @page-speed/video
# or
yarn add @page-speed/video

Usage

Basic Usage

import { Video } from "@page-speed/video";

export default function MyComponent() {
  return (
    <Video
      src="https://example.com/video.mp4"
      poster="https://example.com/poster.jpg"
      controls
    />
  );
}

With HLS Master Playlist

import { Video } from "@page-speed/video";

export default function MyComponent() {
  return (
    <Video
      masterPlaylistUrl="https://cdn.example.com/video/master.m3u8"
      fallbackSrc="https://example.com/video.mp4"
      poster="https://example.com/poster.jpg"
      controls
    />
  );
}

With OptixFlow Poster Optimization

import { Video } from "@page-speed/video";

export default function MyComponent() {
  return (
    <Video
      src="https://example.com/video.mp4"
      poster="https://example.com/poster.jpg"
      optixFlowApiKey="your-api-key"
      controls
    />
  );
}

Global Configuration

import { VideoDefaults } from "@page-speed/video";

export default function App({ children }) {
  return (
    <VideoDefaults optixFlowApiKey="your-api-key">
      {children}
    </VideoDefaults>
  );
}

CDN Usage (UMD)

<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@page-speed/video/dist/browser/page-speed-video.umd.js"></script>

<script>
  const { Video } = PageSpeedVideo;

  ReactDOM.render(
    React.createElement(Video, {
      src: 'https://example.com/video.mp4',
      poster: 'https://example.com/poster.jpg',
      controls: true
    }),
    document.getElementById('root')
  );
</script>

API

Video Props

Extends all native <video> element props, plus:

PropTypeDefaultDescription
srcstring-Source video URL (progressive MP4 or for transform)
masterPlaylistUrlstring-Direct HLS master playlist URL (skips transform)
fallbackSrcstring-Fallback progressive MP4 URL if HLS fails
optixFlowApiKeystring-OptixFlow API key for poster optimization
transformBaseUrlstringhttps://octane.buzzBase URL for transform API
cdnBaseUrlstringhttps://octane.cdn.ingCDN base URL for playlist/segment serving
preferNativeControlsbooleantrueUse native video controls
processingStrategy"optimistic" | "poll""optimistic"Video processing strategy
onPlaybackStateChange(state: PlaybackState) => void-Callback for playback state changes
debugbooleanfalseEnable debug logging

Processing Strategies

  • optimistic: Immediately attempts HLS playback (default, fastest)
  • poll: Waits for video processing to complete before playback

Playback States

  • idle: No video loaded
  • loading: Loading video/manifest
  • ready: Ready to play
  • error: Fatal error occurred

Browser Support

  • Modern Browsers: Chrome, Firefox, Edge (via hls.js)
  • Safari/iOS: Native HLS support
  • Fallback: Progressive MP4 for unsupported browsers

Testing

The package includes a comprehensive test suite with 129 passing tests covering all functionality.

Run Tests

pnpm test

Run Tests with Coverage

pnpm test -- --coverage

Test Coverage

  • ✅ Video component (19 tests)
  • ✅ VideoDefaults component (9 tests)
  • ✅ Transform API client (16 tests)
  • ✅ HLS hook (12 tests)
  • ✅ MP4 fallback logic (26 tests)
  • ✅ Polling strategy (17 tests)
  • ✅ Poster optimization (13 tests)
  • ✅ Integration smoke tests (17 tests)

See TEST_DOCUMENTATION.md for detailed test documentation.

License

BSD-3-Clause

Author

OpenSite AI (https://opensite.ai)

Keywords

react

FAQs

Package last updated on 19 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts