Socket
Socket
Sign inDemoInstall

@vercel/speed-insights

Package Overview
Dependencies
0
Maintainers
9
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @vercel/speed-insights

Speed Insights is a tool for measuring web performance and providing suggestions for improvement.


Version published
Weekly downloads
298K
decreased by-4.22%
Maintainers
9
Created
Weekly downloads
 

Package description

What is @vercel/speed-insights?

@vercel/speed-insights is an npm package designed to provide insights into the performance of web applications. It leverages Google's Lighthouse to analyze and generate reports on various performance metrics, helping developers optimize their applications for better speed and user experience.

What are @vercel/speed-insights's main functionalities?

Generate Performance Report

This feature allows you to generate a performance report for a given URL. The `getSpeedInsights` function fetches the performance metrics and returns a detailed report.

const { getSpeedInsights } = require('@vercel/speed-insights');

async function generateReport(url) {
  const report = await getSpeedInsights({ url });
  console.log(report);
}

generateReport('https://example.com');

Custom Configuration

This feature allows you to customize the performance report by specifying options such as the strategy (mobile or desktop) and the categories of metrics to include in the report.

const { getSpeedInsights } = require('@vercel/speed-insights');

async function generateCustomReport(url) {
  const options = {
    strategy: 'mobile',
    categories: ['performance', 'accessibility']
  };
  const report = await getSpeedInsights({ url, options });
  console.log(report);
}

generateCustomReport('https://example.com');

Save Report to File

This feature allows you to save the generated performance report to a file. The `fs` module is used to write the report data to a specified file path.

const { getSpeedInsights } = require('@vercel/speed-insights');
const fs = require('fs');

async function saveReportToFile(url, filePath) {
  const report = await getSpeedInsights({ url });
  fs.writeFileSync(filePath, JSON.stringify(report, null, 2));
  console.log(`Report saved to ${filePath}`);
}

saveReportToFile('https://example.com', './report.json');

Other packages similar to @vercel/speed-insights

Readme

Source

Speed Insights

Vercel Speed Insights
Performance insights for your website

Website · Documentation · Twitter

Overview

@vercel/speed-insights automatically tracks web vitals and other performance metrics for your website.

This package does not track data in development mode.

It has 1st class integration with:

FrameworkPackage
Next.js@vercel/speed-insights/next
Nuxt@vercel/speed-insights/nuxt
Sveltekit@vercel/speed-insights/sveltekit
Remix@vercel/speed-insights/remix
React@vercel/speed-insights/react
Astro@vercel/speed-insights/astro
Vue@vercel/speed-insights/vue

It also supports other frameworks, vanilla JS and static websites.

Quickstart

  1. Enable Vercel Speed Insights for a project in the Vercel Dashboard.

  2. Add the @vercel/speed-insights package to your project

  3. Inject Speed Insights to your app

    • If you are using Next.js, React, Nuxt or Vue you can use the framework-specific <SpeedInsights /> component to inject the script into your app.
    • If you are using Sveltekit, you can use the injectSpeedInsights() function @vercel/speed-insights/sveltekit in your top-level +layout.js/ts file.
    • For other frameworks, you can use the inject function add the tracking script to your app.
    • If you want to use Vercel Speed Insights on a static site without npm, follow the instructions in the documentation.
  4. Deploy your app to Vercel and see data flowing in.

Documentation

Find more details about this package in our documentation.

Keywords

FAQs

Last updated on 24 May 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc