Skip to content

GuideGetting Started

Svelte Installation Guide

Install Video.js in Svelte or SvelteKit and build a video player with HTML custom elements

Svelte and SvelteKit apps use Video.js HTML custom elements directly in their markup. These lightweight, framework-free components build accessible, customizable players with small bundles, advanced features, and consistent behavior across browsers.

AI Quickstart

Paste this prompt into your coding agent:

Install the Video.js skill using one method. In Codex, run `codex plugin marketplace add videojs/skills`, then `codex plugin add videojs@videojs`, and start a new session. In Claude Code, run `claude plugin marketplace add videojs/skills`, then `claude plugin install videojs@videojs`, and start a new session or run `/reload-plugins`. In VS Code or Cursor, install `https://github.com/videojs/skills` as a plugin from source. For another agent, run `npx skills add https://github.com/videojs/skills --skill videojs` and select the agent. Then use the Video.js skill when working on this project.

Choose your JS framework

Choose the JavaScript framework for your project.

ReactComponents and hooks for React 19HTMLCustom elements for any stackVueVue 3 and Nuxt, using the custom elementsSvelteSvelte 5 and SvelteKit, using the custom elements

Choose your use case

Choose the ready-made player that is closest to what you are building.

VideoOn-demand video with full controlsAudioPodcasts, music, and audio-only playbackLive VideoStreams with a Live button, no durationLive AudioLive radio and audio streamsBackground VideoMuted, looping video behind your content

Choose your skin

Choose how your player looks. You can add the files for any skin to your project and edit them later.

DefaultComplete controls with a modern, frosted lookMinimalThe same controls with clean, solid surfacesNo skinBring your own UI built from the components
0:00
Video preset with the default skin, playing our demo media.

Choose your media source

Paste a media URL to detect its source type, pick one directly, or upload a video to Mux. The generated packages and component update with your choice.

Optional. The URL also ends up in your generated code.

HTML5 VideoMP4, WebM, and other file URLsHLSAdaptive .m3u8 streams via hls.jsDASHAdaptive .mpd streams via dash.jsMuxPlayback IDs with Mux Data built inVimeoVimeo videos and private linksYouTubeYouTube videos and shortsCloudflare StreamCloudflare Stream videosTikTokTikTok videosTwitchTwitch channels, videos, and clips
Drop a video to host it for free on MuxWe transcode it into an HLS stream and set it as your source above.orPowered by

Choose how to install

Choose from the installation options available for your selections. Shadcn adds editable HTML custom-element source to your Svelte project.

Install the packages

Install the HTML elements and any playback adapter your selected media source needs.

npm install @videojs/html

Add your player

Add a component that imports the elements it renders. Svelte passes hyphenated tags through to the browser, so no compiler configuration is needed. The imports register the selected player, skin, media, and extensions; the markup composes them.

<script lang="ts">
  import '@videojs/html/video/player';
  import '@videojs/html/video/skin';

  let { src }: { src: string } = $props();
</script>

<!--
  The player element owns and shares state between the UI
  components and Media. Put layout on the skin or container.
 -->
<video-player>
  <!--
    Skins contain the entire player UI and are easily swappable.
    Add the skin source to your project for full control over its
    UI components.
   -->
  <video-skin>
    <!--
        Media are players without UIs, handling networking
        and display of the media. They are easily swappable
        to handle different sources.
      -->
    <video src={src} playsinline></video>
  </video-skin>
</video-player>

Then render the component in a page and pass it the media source you selected above.

<script lang="ts">
  import VideoPlayer from '$lib/VideoPlayer.svelte';
</script>

<h1>Welcome to My App</h1>
<VideoPlayer src="https://stream.mux.com/BV3YZtogl89mg9VcNBhhnHm02Y34zI1nlMuMQfAbl3dM/highest.mp4" />

That’s it! You now have a working Video.js player.

Own the UI

Packaged skins keep their controls and layout inside Video.js. When you need to add, remove, rearrange, or deeply restyle controls, use Shadcn to add the skin source to your project. Its components, layout, styles, and interactions become local files you can change.

Choose what to do next

Customize

Deploy

Something not quite right? You can submit an issue and ask for help, or explore other support options.