We use cookies to ensure you get the best experience on our website. Read our privacy policy

Skip to main content

Directory

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.

Key features include:

  • Check Circle

    Dual Modes: Standard player and background video modes

  • Check Circle

    Smart Loading: Videos load only when needed and preload distance is configurable

  • Check Circle

    Accessibility: Keyboard controls and ARIA support

  • Check Circle

    Customizable: Flexible styling and behavior options

  • Check Circle

    SEO-friendly: Structured data support

  • Check Circle

    Responsive: Adapts to different screen sizes

Perfect for content-focused videos with controls:

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

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"
/>
Required Props
Native Video Component Props Extends <video> HTMLElement
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

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
}

The component exposes the following function for you to use:

play(): Promise<void>;
  • 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

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!
North Star Themes Logo

Subscribe to our newsletter

Get the latest AstroJS tips and tricks right to your inbox

Email: [email protected]

© 2025 North Star Themes

Web Kit Provided By North Star Themes