#Use npm packages in Nuxt

1 messages · Page 1 of 1 (latest)

lone pivot
#

Hello, I want to use npm packages inside my Nuxt App, for now the lib I want to use is js-confetti, I ran into the document issue so I made some research and got the point where I made a "plugins" folder with a confetti.js file inside, wrote that

import JSConfetti from "js-confetti"

export default defineNuxtPlugin((nuxtApp) => {
    const confetti = new JSConfetti()
})

then that

import JSConfetti from "js-confetti"

export default defineNuxtPlugin((nuxtApp) => {
    provide: {
        confetti = new JSConfetti()
    }
})

with that in my component

function showConfetti() {
  $confetti().addConfetti()
}

obviously none works so I'm kind of running out of ideas

rain patrol
#

suggestion: create a composable instead