Vue Lite YouTube Embed Component

1.2.4 · active · verified Sun Apr 19

vue-lite-youtube-embed is a lightweight Vue component designed to embed YouTube videos with a strong focus on performance and user privacy. It serves as a Vue port of React Lite YouTube Embed, implementing an "Adaptive Loading" strategy to defer loading the full YouTube iframe until user interaction, significantly improving initial page load times. The package is currently at version 1.2.4 and appears to have an ad-hoc release cadence, typical for focused utility components. Its primary differentiators include being private-by-default (using `youtube-nocookie.com` if `cookie` prop is set to true), requiring only essential assets, and providing a clean, customizable interface. It supports both Vue 2 (with a `vue-frag` dependency) and Vue 3, shipping with TypeScript types for enhanced developer experience. It prioritizes accessibility by requiring a `title` prop for the iframe.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the LiteYouTubeEmbed component in a Vue 3 application, including importing its CSS, setting required props like `id` and `title`, and showcasing optional features like privacy-enhanced mode and custom `params`.

import { createApp } from 'vue'
import LiteYouTubeEmbed from 'vue-lite-youtube-embed'
import 'vue-lite-youtube-embed/style.css'

const App = {
  template: `
    <div>
      <h1>My YouTube Video</h1>
      <LiteYouTubeEmbed
        id="dQw4w9WgXcQ"
        title="Rick Astley - Never Gonna Give You Up (Official Music Video)"
        adNetwork={false}
        cookie={true}
        params="start=60&autoplay=1"
      />
      <p>This video uses the privacy-enhanced mode and starts at 1 minute.</p>
    </div>
  `,
  components: { LiteYouTubeEmbed }
}

createApp(App).mount('#app')

view raw JSON →