npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

payload-plugin-pagespeed

v0.2.1

Published

A Payload CMS plugin that integrates PageSpeed Insights into your project.

Readme

payload-plugin-pagespeed-banner

npm version npm downloads license GitHub stars

payload-plugin-pagespeed

A Payload CMS plugin that integrates Google PageSpeed Insights into your project. Use it to analyze pages and view performance metrics directly in your Payload admin ui.

Features

  • 🔍 Run PageSpeed Insights checks on demand
  • 📊 Store results in a Payload collection
  • ⚡ Simple setup with minimal configuration
  • 🛠 Works with your existing PayloadCMS project

Demo

payload-plugin-pagespeed-demo.webm

Installation

pnpm add payload-plugin-pagespeed

Getting Started

[!IMPORTANT]
Make sure to get a PageSpeed Insights API key as this plugin requires one to communicate with the PageSpeed API.

Add the plugin to your payload.config.ts:

import { buildConfig } from 'payload/config'
import { pageSpeedPlugin } from 'payload-plugin-pagespeed'

export default buildConfig({
  // ... your config
  plugins: [
    // ... your other plugins
    pageSpeedPlugin({
      apiKey: process.env.PAGESPEED_API_KEY, // Required
    }),
  ],
})

Now start your Payload app:

pnpm dev

You’ll see a new collection in the admin panel where your PageSpeed Insight reports are stored, by default this is the PageSpeed Insights collection.

Usage

  1. Go to the PageSpeed Insights collection in the Payload admin.
  2. Create a new entry with a URL.
  3. The plugin will fetch results from Google PageSpeed Insights and save them (This may take a while as the PageSpeed Insights API analyzes your page).
  4. View metrics such as Performance, Accessibility, SEO, and Best Practices.

create-new-doc

Configuration

The plugin accepts the following options:

| Key | Type | Description | | :--- | :--- | :--- | | apiKey* | string (required) | A Google PageSpeed Insights API key. | | debug | boolean | A boolean that, when true, shows debug information and the hidden reports collection. | | disabled | boolean | A boolean that, when true, prevents the plugin from mounting the api endpoint in collection config. | | generateFileName | function (GenerateFileNameFn) | An optional function that is invoked to generate a filename for a PageSpeed Insights report object. | | generateFilePrefix | function (GenerateFilePrefixFn) | An optional function that is invoked to generate a file prefix for a PageSpeed Insights report object if using a storage adapter. | | overrideInsightsCollection | function (CollectionOverride) | A function used to override the default PageSpeed Insights collection. | | overrideReportsCollection | function (CollectionOverride) | A function used to override the default PageSpeed Reports collection. |

[!NOTE] In order to successfully work, the user making the request needs to have both read and create access for the PageSpeed Insights collection. In addition, this plugin sets the update access control on the PageSpeed Insights collection to false. An example below shows customizing access controls and other collection configs.

Example plugin configurations

import { buildConfig } from 'payload/config'
import { pageSpeedPlugin } from 'payload-plugin-pagespeed'

export default buildConfig({
  // ... your config
  plugins: [
    // ... your other plugins
    pageSpeedPlugin({
      apiKey: process.env.PAGESPEED_API_KEY, // Required
      overrideInsightsCollection: (collection) => ({
        ...collection,
        access: {
          ...collection,
          read: () => true, // Anyone can read the insights collection
          create: () => true, // Anyone can create an insights report
        }
        // ... other overrides
      })
    }),
  ],
})
import { s3Storage } from '@payloadcms/storage-s3'
import { buildConfig } from 'payload/config'
import { pageSpeedPlugin } from 'payload-plugin-pagespeed'

export default buildConfig({
  // ... your config
  plugins: [
    // ... your other plugins
    s3Storage({
      bucket: process.env.S3_BUCKET || '',
      collections: {
        'pagespeed-reports': true,
      },
      config: {
        credentials: {
          accessKeyId: process.env.S3_ACCESS_KEY_ID || '',
          secretAccessKey: process.env.S3_SECRET || '',
        },
        endpoint: process.env.S3_ENDPOINT || '',
        region: process.env.S3_REGION || '',
      },
    })
    pageSpeedPlugin({
      apiKey: process.env.PAGESPEED_API_KEY, // Required
      generateFilePrefix: ({ collection, req }) => { ... } // Save to specific folder in storage
    }),
  ],
})

API Reference

HTTP request

GET <api-route>/<insights-slug>/:id?/report

The URL segment for api-route is your Payload configured base API route (by default /api), insights-slug is the collection slug for the PageSpeed Insights collection (by default pagespeed-insights), and :id? is an optional parameter representing a PageSpeed Insights doc id.

Query parameters

If a doc id is passed as a url segment, then the query parameters are overriden by the fields in the doc. To view available query parameters, see the PageSpeed API Reference.

Example HTTP request

If no doc id is provided, then the url query parameter is required.

GET /api/pagespeed-insights/report?url=https://payloadcms.com

Example HTTP request with doc id

GET /api/pagespeed-insights/68aa352d42f08695dd833412/report

Response body

A successful request will return:

| Parameter | Type | Description | | :--- | :--- | :--- | | report | PageSpeedReportObject \| string \| number | The pagespeed report. This will be a document id if the insights document already has a report generated. | | message | string | A message containing the status message of the operation. |

Contributing

Contributions are welcome!

If you’d like to improve this plugin, feel free to open an issue or PR.

License

MIT © 2025 saikhon.dev