Vue-plyr is a component library that provides a seamless integration of the robust Plyr.io media player into Vue.js applications. It supports HTML5 video and audio, as well as embeds from YouTube and Vimeo, offering a consistent and customizable player experience. Currently at version 7.0.0, vue-plyr aligns with modern Vue 3 applications while also providing backward compatibility for Vue 2. Its release cadence typically follows updates to the underlying Plyr library and major Vue.js versions. A key differentiator is its straightforward API for embedding various media types and accessing the underlying Plyr instance for advanced control, simplifying the process compared to integrating Plyr directly. The library also includes specific support for Server-Side Rendering (SSR) environments like Nuxt.js, addressing common challenges in universal applications.
npm install vue-plyrVerified import paths — ran on the pinned version, not inferred.
Initializes a Vue 3 application, globally registers the `VuePlyr` component with default options, and demonstrates embedding an HTML5 video player.
For Vue 3.x, use `createApp(App).use(VuePlyr, { plyr: {} }).mount('#app')`. For Vue 2.x, continue using `Vue.use(VuePlyr, { plyr: {} })`.Ensure `import 'vue-plyr/dist/vue-plyr.css'` is included in your main application entry file (e.g., `main.js` or `main.ts`).
Import the SSR-specific build: `import VuePlyr from 'vue-plyr/dist/vue-plyr.ssr.js'`. Refer to the package's SSR documentation for detailed Nuxt.js integration.
Add a ref to your component `<vue-plyr ref="plyrRef">` and then access `this.$refs.plyrRef.player` in your component's methods or lifecycle hooks.
For Vue 3, use the application instance's `use` method: `createApp(App).use(VuePlyr).mount('#app')`.Add `import 'vue-plyr/dist/vue-plyr.css'` to your application's entry point (e.g., `main.js`, `main.ts`).
Import the SSR-optimized version of the component: `import VuePlyr from 'vue-plyr/dist/vue-plyr.ssr.js'` in your SSR-specific files or use dynamic imports for client-only components.