Open akserikawa opened 1 year ago
Managed to make it work with this workaround:
// plugins/pusher.js
import Pusher from "pusher-js";
export default defineNuxtPlugin((nuxtApp) => {
const Vue3Pusher = {
install: (app, options) => {
var pusher = new Pusher(options.api_key, options.options);
app.config.globalProperties.$pusher = pusher;
},
};
nuxtApp.vueApp.use(Vue3Pusher, {
api_key: "****",
options: {
cluster: "eu",
},
});
});
Managed to make it work with this workaround:
// plugins/pusher.js import Pusher from "pusher-js"; export default defineNuxtPlugin((nuxtApp) => { const Vue3Pusher = { install: (app, options) => { var pusher = new Pusher(options.api_key, options.options); app.config.globalProperties.$pusher = pusher; }, }; nuxtApp.vueApp.use(Vue3Pusher, { api_key: "****", options: { cluster: "eu", }, }); });
How did you use it inside component?
Trying to install the plugin on a Vue 3 project (w/ Nuxt 3) it errors:
this caused by changes in Vue 3, where
Vue.prototype
does not exist anymore, so the plugin cannot work:I guess it would require the plugin to use
app.config.globalProperties
instead.https://vuejs.org/api/application.html#app-config-globalproperties