Directory
- Welcome
Native Video Component
The Native Video component provides a powerful way to embed videos directly in your application, with support for both standard playback and background video scenarios. It offers lazy loading, accessibility features, and customizable controls.
Overview
Key features include:
-
Dual Modes: Standard player and background video modes
-
Smart Loading: Videos load only when needed and preload distance is configurable
-
Accessibility: Keyboard controls and ARIA support
-
Customizable: Flexible styling and behavior options
-
SEO-friendly: Structured data support
-
Responsive: Adapts to different screen sizes
Usage Examples
Standard Player Mode
Perfect for content-focused videos with controls:

<VideoNative src="/videos/example.mp4" thumbnail={{ src: thumbnailImage, alt: "Video description" }} player="player"/>
Background Mode

Ideal for hero sections and decorative content. The video will play automatically with no visible controls.
<VideoNative src="/videos/background.mp4" thumbnail={{ src: thumbnailImage, alt: "Background video" }} player="background"/>
Native Video Component Props API
Prop | Type | Default | Description |
---|---|---|---|
src | string | - | URL of the video file |
thumbnail | object | - | Thumbnail image configuration |
player | "player" | "background" | player | Video player mode |
aspectRatio | "16/9" | "4/3" | "1/1" | 16/9 | Video container aspect ratio |
autoplay | boolean | true | Auto-play video on load |
muted | boolean | true | Mute video by default |
loop | boolean | true | Loop video playback |
controls | boolean | true | Show video controls (player mode only) |
preload | "none" | "metadata" | "auto" | metadata | Video preload behavior |
preloadDistance | number | 100 | Preload distance for background mode |
structuredData | boolean | true | Enable SEO structured data |
Thumbnail Configuration
The thumbnail object accepts the following properties:
{ src: ImageMetadata; // Image source alt: string; // Alt text class?: string; // Optional CSS classes size?: 'fit' | 'fill'; // Image sizing mode}
Functions
The component exposes the following function for you to use:
play(): Promise<void>;
Accessibility Features
- Keyboard Controls:
- Space/Enter: Play/Pause
- Arrow Right: Forward 5 seconds
- Arrow Left: Backward 5 seconds
- M: Toggle mute
- ARIA Labels: Automatic labeling for controls
- Focus Management: Proper tab order
Structured Data
The component automatically generates VideoObject structured data for SEO:
{ title?: string; // Video title description?: string; // Video description uploadDate?: Date; // Publication date structuredDataProps?: Partial<VideoObject>; // Additional properties}
Limited Time Launch Sale
Start creating engaging video experiences with our Native Video component. Get the AstroJS starter template now and implement professional video features in minutes.
GET 60% OFF!