
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
vue-youtube-vue-3
Advanced tools
vue-youtube is an wrapper of YouTube IFrame Player API (YIPA).
What is the difference between other plugins? The difference is that the function body is wrapped in a promise. This promise is resolved only when the player has finished loading and is ready to begin receiving API calls (onReady). Therefore, all function calls are queued and replayed only when player is ready.
You can do something like:
export default {
// ...
computed: {
player() {
return this.$refs.youtube.player
}
},
methods: {
async playVideo() {
await this.player.playVideo()
// Do something after the playVideo command
}
}
}
Live demo built on top of the awesome codesandbox.
npm install vue-youtube
# or
yarn add vue-youtube
import Vue from 'vue'
import VueYoutube from 'vue-youtube'
Vue.use(VueYoutube)
<!-- Include after Vue -->
<!-- Local files -->
<script src="vue-youtube/dist/vue-youtube.js"></script>
<youtube :video-id="videoId" ref="youtube" @playing="playing"></youtube>
<button @click="playVideo">play</button>
export default {
data() {
return {
videoId: 'lG0Ys-2d4MA'
}
},
methods: {
playVideo() {
this.player.playVideo()
},
playing() {
console.log('\o/ we are watching!!!')
}
},
computed: {
player() {
return this.$refs.youtube.player
}
}
}
or
<youtube :video-id="videoId" :player-vars="playerVars" @playing="playing"></youtube>
export default {
data() {
return {
videoId: 'lG0Ys-2d4MA',
playerVars: {
autoplay: 1
}
}
},
methods: {
playing() {
console.log('\o/ we are watching!!!')
}
}
}
The component triggers events to notify the parent component of changes in the player. For more information, see YouTube IFrame Player API.
| Events => | ready | ended | playing | paused | buffering | cued | error |
|---|
You have access to all api methods through component referencing.
Example:
<youtube video-id="lG0Ys-2d4MA" ref="youtube"></youtube>
export default {
// ...
methods: {
playVideo() {
this.$refs.youtube.player.playVideo()
}
}
}
| Prop | Type(s) | Default | Description |
|---|---|---|---|
| width | Number, String | 640 | iframe pixel width |
| height | Number, String | 360 | iframe pixel height |
| resize | Boolean | false | iframe will proportionally scale height with its width |
| resizeDelay | Number | 200 | Delay in milliseconds before running resize callback |
| fitParent | Boolean | false | iframe will use its parent's width |
| nocookie | Boolean | false | Change host param to www.youtube-nocookie.com |
Resizing proportionally (resize) works best with a parent element. The parent element is used for a width reference. fitParent should be on in most situations. It allows resize to work without appyling CSS any properties to your iframe. If you want to turn fitParent off, you can emulate it with CSS by setting width to 100%, like so:
iframe {
width: 100%;
max-width: 650px; /* Also helpful. Optional. */
}
New in v1.2.0
Function{String} url{Object} options...
methods: {
getId () {
return this.$youtube.getIdFromUrl(this.video.url)
}
}
...
or
import { getIdFromUrl } from 'vue-youtube'
const myFunction = (url) => {
const youtubeId = getIdFromUrl(url)
// ...
}
FAQs
YouTube IFrame Player API wrapper
The npm package vue-youtube-vue-3 receives a total of 200 weekly downloads. As such, vue-youtube-vue-3 popularity was classified as not popular.
We found that vue-youtube-vue-3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.