Live annotation overlay for Hiyve video tiles. Drop a transparent canvas on top of a screen-share (or any video) and let participants draw on it; strokes replicate to every peer in real time.
npm install @hiyve/react-annotations @hiyve/react @hiyve/core @hiyve/utilities @mui/material
import { useState, useRef } from 'react';
import {
AnnotationCanvas,
AnnotationToolbar,
useAnnotationSync,
} from '@hiyve/react-annotations';
function ScreenShareTile({ videoRef, shareId, localUserId, isOwner, isSharer }) {
const [tool, setTool] = useState({ color: '#ff3366', width: 0.004 });
const sync = useAnnotationSync({ shareId, localUserId, isOwner, isSharer });
return (
<>
<AnnotationCanvas
videoRef={videoRef}
shareId={shareId}
localUserId={localUserId}
isOwner={isOwner}
isSharer={isSharer}
tool={tool}
sync={sync}
/>
<AnnotationToolbar
tool={tool}
onToolChange={setTool}
onClearMine={sync.clearMine}
onClearAll={sync.clearAll}
canClearAll={sync.canClearAll}
/>
</>
);
}
<video> element and tracks its content rect (handles objectFit: contain letterbox / pillarbox math).HiyveProvider from @hiyve/react.<video> element ref to overlay (typically the screen-share tile's video).| Export | Kind | Purpose |
|---|---|---|
AnnotationCanvas |
component | The transparent SVG overlay |
AnnotationToolbar |
component | Pen + colour swatches + width + clear |
useAnnotationSync |
hook | Stroke state + transport |
useVideoContentRect |
hook | Live content rect of a <video> under objectFit: contain |
useScreenSharingParticipants |
hook | Filter useParticipants() to screen sharers |
Stroke, Point, AnnotationPermission, ... |
types | Public type surface |
DEFAULT_COLORS, DEFAULT_TOOL, ... |
defaults | Sensible starting values + merge functions |
See the per-component README sections below for full prop tables.
Both AnnotationCanvas and AnnotationToolbar accept labels, colors, and styles overrides — same merge-function pattern used elsewhere in the SDK.
@hiyve/react-annotations — Live annotation overlay for Hiyve video tiles. Drop a transparent canvas on top of a screen-share (or any video) and let participants draw on it; strokes replicate to every peer in real time.