Youtube SDK
So i want to show youtube videos on a page ,
so im loading in the sdk with a plugin like this
and in my component i do this :
this works when you only have 1 video, but if you have multiple it only loads the last on , im getting confused
does somebody have some help ?
16 Replies
also it does works when navigation to another page and back it shows the rest , but on initial load or refresh it dont
You should try Nuxt Scripts YouTube embed https://scripts.nuxt.com/scripts/content/youtube-player
Nuxt Scripts
YouTube Player · Nuxt Scripts
Show performance-optimized YouTube videos in your Nuxt app.
@harlan i already tried nuxt scripts but it is broken, when added unhead gives errors on tagElements cannot be mapped ( also nuxt scripts is in beta .. ), so not usable
if you submit an issue for the error i will fix it 👍
anyway you can look at how it's implemented, it doesn't have the issues you're facing
well thats the problem i couldt see it work because after the npx add module ( on fresh nuxt ) it already gives error out of the box so didnt see it working , i can however take a look at the code
can you replicate in the playground https://stackblitz.com/edit/nuxt-starter-pkwfkx?file=pages%2Findex.vue ?
Harlan Wilton
StackBlitz
Minimal Nuxt Scripts - StackBlitz
Create a new Nuxt project, module, layer or start from a theme with our collection of starters.
let me check
ok for some reason i got it working on a new fresh install, i will check ik out later in my current project if it will work,
also @harlan are you a member of nuxt-scripts ?
i am the author
nice ! there is a error on the sdk example for youtube scripts
let player;
should be
const player = ref(null);
the player.playVideo wont work then
this will work
thanks, i've pushed up a fix
i also going to try later this week why im getting the error with unhead after i add nuxt-scripts to my other project
it's likely you have an old version of one of the unhead packages
you can usually fix it by doing a
nuxi upgrade --force
mmm 🤔 i thought i updated latest nuxt version , but thanks for the tip !
i will post an update in this channel ! keep up the good work !!
also cant wait untill its out of beta 🙂
it's not nuxt itself but the dependencies of nuxt which sometimes get stuck
by doing --force it will delete your lock file and node_modules and re-install
which usually solves it
i will give that a try
after the --force upgrade everything works ! thanks @harlan
randomly looking for a fix on my nuxt-mongoose module and stumbled upon this legendary command. Thank you!
PS: Still didn't fix my problem though 😄
and thank you for triggering that response !