@nuxtjs/web-vitals
Version:
Web Vitals for Nuxt.js
14 lines (13 loc) • 440 B
JavaScript
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));
});