UNPKG

@nuxtjs/web-vitals

Version:
14 lines (13 loc) 440 B
import { webVitals } from "./web-vitals.mjs"; import { defineNuxtPlugin, useRouter } from "#imports"; import { sendToAnalytics } from "~web-vitals-provider"; import webVitalsOptions from "#build/web-vitals-config.mjs"; const sendVitals = (to) => webVitals({ options: webVitalsOptions, sendToAnalytics, route: to }); export default defineNuxtPlugin(() => { const router = useRouter(); router.afterEach((to) => sendVitals(to)); });