Open gerritvanaaken opened 1 year ago
Hey. I am also trying to implement this plugin with Nuxt3 and am unable to do this.
If I just try to use components, I get "Failed to resolve component" error in console. If I try adding vue-maplibre-gl
as module to Nuxt config, I get "document is not defined" error in terminal.
What am I missing?
Hey. I am also trying to implement this plugin with Nuxt3 and am unable to do this.
If I just try to use components, I get "Failed to resolve component" error in console. If I try adding
vue-maplibre-gl
as module to Nuxt config, I get "document is not defined" error in terminal.What am I missing?
Create a new plugin "maplibre.client.js"
import VueMaplibreGl from "vue-maplibre-gl";
import "maplibre-gl/dist/maplibre-gl.css";
import "vue-maplibre-gl/dist/vue-maplibre-gl.css";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueMaplibreGl);
});
This plugin seems to be compatible with Nuxt3, which is great! However, one might have to declare the components to be "client only", like so:
Otherwise there is a 500 error, because rhe server does nit has access to the "document" element, of course. This might help :-)