Provides React hooks for warming the network path to video origins, reducing click-to-first-frame latency via preconnects and IntersectionObserver-gated preloads. ## Key Components | Export | Type | Description | |---|---|---| | `saveDataEnabled` | `function` | Detects metered connections via `navigator.connection?.saveData`; SSR-safe | | `useVideoOriginPreconnect` | `hook` | Fires TCP/TLS preconnects to Mux and Supabase Storage origins without IO subscription | | `useVideoWarmup` | `hook` | Full warmup — preconnects on every render + IO-gated `` for Supabase-hosted MP4s | | `MUX_STREAM_ORIGIN` | `const` | Re-exported from `mux-origins.ts` (server-safe module) | | `MUX_IMAGE_ORIGIN` | `const` | Re-exported from `mux-origins.ts` (server-safe module) | **Origin resolution priority:** explicit `supabaseStorageOrigin` arg → `ChatRuntime.endpoints.supabaseStorageOrigin` → preload skipped (Mux preconnects still fire). **Preload gates (all must pass):** 1. Container is within `nearMargin` of viewport (default `1000px`) 2. `saveDataEnabled()` returns `false` 3. `videoUrl` origin matches `supabaseStorageOrigin` (Mux HLS and YouTube are intentional no-ops) ## Usage Example ```typescript // Full warmup — owns the video container ref function VideoCard({ videoUrl }: { videoUrl: string }) { const { ref, isNear } = useVideoWarmup({ videoUrl, nearMargin: '800px', }) return (
{isNear && }
) } // Preconnect-only — no container ref available function ReleasePage() { useVideoOriginPreconnect() return } ``` > **`useVideoOriginPreconnect` vs `useVideoWarmup`:** Use `useVideoOriginPreconnect` when you cannot attach a `ref` to the video container (e.g. a page that delegates rendering to a sibling). Use `useVideoWarmup` when you own the container. **Source:** [`hooks/use-video-warmup.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/hooks/use-video-warmup.ts)