diff --git a/src/nuxt-plugin.ts b/src/nuxt-plugin.ts index 2409a9e..1f17075 100644 --- a/src/nuxt-plugin.ts +++ b/src/nuxt-plugin.ts @@ -36,7 +36,13 @@ const PlausiblePlugin: Plugin = (context, inject) => { plausible.enableAutoOutboundTracking() } - inject('plausible', plausible) + if (inject) { + // Nuxt 2 + inject('plausible', plausible) + } else { + // Nuxt 3 + context.provide('plausible', plausible) + } } export default PlausiblePlugin