GuideGetting Started
Svelte Installation Guide
Install Video.js in Svelte or SvelteKit and build a video player with HTML custom elements
Svelte apps built with Vite, Astro, or SvelteKit 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: run `npx @videojs/cli agents skills` and follow the steps for the agent you are running in. If you can't run commands, follow the install instructions at https://github.com/videojs/skills instead. Then use the Video.js skill when you work on video or audio in this project. When installation details are needed, run `npx @videojs/cli agents init --framework svelte` to print the version-matched choices and instructions without changing files.Installation options for coding agents
The web Markdown page contains the default installation. Add the query parameters below to its .md URL for a complete, validated variation. From a project or an offline docs bundle, run the CLI command below instead. Both paths use the same installation renderer and only return instructions; they do not modify a project.
This page fixes the installation method to packaged and the framework to svelte.
npx @videojs/cli agents initQuery parameters
project: Whether to adapt the current project or scaffold a new one. New projects need a named app setup. Values:new,existing. Default: existing.preset: The player configuration and control set. Values:video,audio,live-video,live-audio,background-video. Default: video.skin: The visual skin. Neutral has cleaner surfaces and the same controls as Default. Values:default,neutral,compat,scaffold,none. Default: default. Applies when preset is not background-video.media: The media source or playback adapter. See the preset compatibility map below. Values:background-video,hls-background-video,cloudflare,dash,hls,html5-audio,html5-video,mux-audio,mux-background-video,mux-video,spotify,tiktok,twitch,vimeo,youtube. Default: the selected preset's first compatible media source.extensions: A comma-separated list of optional player extensions compatible with the selected player. Passnonewhen no extension is needed. Values:none,google-cast,mux-data. Default: mux-data for Mux media; none otherwise (reported as defaulted).source-url: The http:// or https:// media URL placed in the generated player example. Passdemoto choose the Video.js demo source for the selected media explicitly. Default: the Video.js demo source for the selected media (reported as defaulted).package-manager: The command runner used for app setup, packages, Shadcn, and the development server. Values:npm,pnpm,yarn,bun. Default: pnpm. Applies when method is not cdn with template none.template: The app setup and file layout. Values:vite,astro,sveltekit. Default: vite.
Run the command above without flags to see the corresponding CLI flags for every framework.
Decide in this order
- Inspect the project. Read package.json, framework config, and lockfiles to infer the framework, app setup, and package manager. React installs @videojs/react; HTML, Vue, and Svelte install @videojs/html. In a workspace with several apps, choose the app the request names and run the command from its directory, since detection reads the package.json where it runs. When the request does not identify one app, ask: "Which app should get the player: <app> or <app>?" Without an answer, choose the app that serves the page the request describes and report that choice.
- Check for Video.js 8. The
video.jspackage,class="video-js",data-setup, or avideojs(...)call means existing pages run Video.js 8. Build new players with Video.js 10, which uses separate@videojs/*packages, and leave existing Video.js 8 players unchanged. Migrate one only when the user asks, following the Migrate from Video.js 8 guide instead of this plan. When the request could mean replacing an existing player, ask: "Should I migrate the existing Video.js 8 player, or add a Video.js 10 player and leave it as it is?" Without an answer, add the Video.js 10 player. Tell the user the project now uses both versions and that the Video.js 8 players can be migrated later. - Choose the starting point. Use existing when adapting a compatible project. Use new only when the user wants a new app or the intended workspace has no app. When the workspace and request do not make it clear, ask: "Should I add the player to the existing app or create a new one?" Without an answer, use existing when an app exists.
- Choose the player. Use video unless the request signals another experience: audio, music, or podcasts use audio; a live stream uses live-video or live-audio; a muted, looping decorative video uses background-video. Ask only when those signals conflict.
- Choose the skin. Use default unless the request asks for a minimal, cleaner, or more subtle look, which uses neutral; both contain the same controls. Use none only when the project builds its own controls. Ask only when those signals conflict.
- Choose the media. Infer the adapter from the source when possible. Mux wins for Mux playback URLs: stream.mux.com/<playback-id>.m3u8 or a bare playback ID uses mux-video, mux-audio, or mux-background-video rather than hls. Mux static renditions such as .mp4 or .m4a files use html5-video or html5-audio. Other .m3u8 URLs use hls.
- Choose extensions. Mux Data is included by default for Mux video and audio sources. Add Google Cast when a standard or live video player with a ready-made skin should cast a compatible source. Use none when no extension is needed.
- Choose how to install. This guide uses packaged modules, which need a bundler. Match the package manager to the project lockfile. For an existing HTML site without a build step, use CDN scripts instead.
- Return one explicit plan. Put any questions from the steps above in one message, each with the default you would otherwise use, and ask nothing when the signals agree. When you cannot ask, use those defaults and report each one with the result. Then pass every applicable query parameter, including
extensions=nonewhen no extension is needed andsource-url=demowhen there is no media URL yet. Check that Defaulted options says none. Adapt conditional setup steps and existing paths before changing files.
Compatible media sources by preset
video:html5-video,hls,dash,mux-video,vimeo,youtube,cloudflare,tiktok,twitchaudio:html5-audio,mux-audio,spotifylive-video:hls,mux-videolive-audio:mux-audiobackground-video:background-video,hls-background-video,mux-background-video
App setup by framework
svelte: templatesvite,astro,sveltekit
Installation pages
Choose your framework
Choose the JavaScript framework for your project.
Choose your app
Choose whether the instructions target a Vite, Astro, or SvelteKit app.
Choose your use case
Choose the ready-made player that is closest to what you are building.
Choose your skin
Choose how your player looks. You can add the files for any skin to your project and edit them later.

Choose your media
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.
Choose your extensions
Add optional behavior to the player. Only extensions that work with your player and media source appear below.
No optional extensions apply to these selections.
Prepare your app
Choose whether to create the selected Svelte app setup or add Video.js to a project you already have.
Install the packages
Install the HTML elements and any playback adapter your selected media source needs.
Add your player
Add the player component
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.
Render the player
Render the component in a page and pass it the media source you selected above.
Run your app
Start the app and verify that the selected media plays.
That’s it! You now have a working Video.js player.
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.