Skip to main content

Web Vitals

The Web Vitals API allows you to access performance metrics for your app directly through App Bridge.

The Web Vitals API provides an onReport method that registers a callback function to receive Web Vitals data. It allows you to monitor and analyze your app's performance in the Shopify admin.

(callback: ) => Promise<void>
Was this section helpful?

Callback onReport

// Define the callback function
const callback = async (metrics) => {
const monitorUrl = 'https://yourserver.com/web-vitals-metrics';
const data = JSON.stringify(metrics);

navigator.sendBeacon(monitorUrl, data);
};

// Register the callback
shopify.webVitals.onReport(callback);