akhrarovsaid

payload plugin pagespeed

by akhrarovsaid
Analytics
v3
^3.50.0
MIT

Overview

Summary generated from the README

Integrates Google PageSpeed Insights into the Payload admin. Creating an entry with a URL fetches a report from the PageSpeed API and saves it in a collection, showing Performance, Accessibility, SEO and Best Practices scores. Requires a PageSpeed Insights API key and Payload 3.50 or later.

Features

  • Runs PageSpeed Insights analysis on demand from a URL entry in the admin
  • Stores reports in a Payload collection, with an optional hidden reports collection
  • Exposes a REST endpoint to generate a report by URL or by document id
  • Overrides for the insights and reports collections, including access control
  • Works with storage adapters, with custom file name and prefix generators

Use cases

  • Track performance and accessibility scores of site pages from inside the Payload admin
  • Keep a history of Lighthouse metrics for pages to monitor changes over time

From the author

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

Installation

npm i payload-plugin-pagespeed

50

Stars

1

Forks

0

Open Issues

1 years ago

Last Updated

131

Weekly Downloads

v0.2.1

npm Version

222.0 KB

Unpacked Size

0

Dependencies

GitHub stars

500 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 202650
Dec 5, 202650
Dec 4, 202650
Dec 3, 202650
Dec 2, 202650
Dec 1, 202650
Nov 30, 202650
Nov 29, 202650
Nov 28, 202650
Nov 27, 202650
Nov 26, 202650
Nov 25, 202650
Nov 24, 202650
Nov 23, 202650
Nov 22, 202650
Nov 21, 202650
Nov 20, 202650
Nov 19, 202650
Nov 18, 202650
Nov 17, 202650
Nov 16, 202650
Nov 15, 202650
Nov 14, 202650
Nov 13, 202650
Nov 12, 202650
Nov 11, 202650
Nov 10, 202650
Nov 9, 202650
Nov 8, 202650
Nov 7, 202650
Nov 6, 202650
Nov 5, 202650
Nov 4, 202650
Nov 3, 202650
Nov 2, 202650
Nov 1, 202650
Oct 31, 202650
Oct 30, 202650
Oct 29, 202650
Oct 28, 202650
Oct 27, 202650
Oct 26, 202650
Oct 25, 202650
Oct 24, 202650
Oct 23, 202650
Oct 22, 202651
Oct 21, 202650
Oct 20, 202650
Oct 19, 202650
Oct 18, 202650
Oct 17, 202650
Oct 16, 202650
Oct 15, 202650
Oct 14, 202650
Oct 13, 202650
Oct 12, 202650
Oct 11, 202650
Oct 10, 202650
Oct 9, 202650
Oct 8, 202650
Oct 7, 202650
Oct 6, 202650
Oct 5, 202650
Oct 4, 202650
Oct 3, 202650
Oct 2, 202650
Oct 1, 202650
Sep 30, 202650
Sep 29, 202650
Sep 28, 202650
Sep 27, 202650
Sep 26, 202650
Sep 25, 202650
Sep 24, 202650
Sep 23, 202650
Sep 22, 202650
Sep 21, 202650
Sep 20, 202650
Sep 19, 202650
Sep 18, 202650
Sep 17, 202650
Sep 16, 202650
Sep 15, 202650
Sep 14, 202650
Sep 13, 202650
Sep 12, 202650
Sep 11, 202650
Sep 10, 202650
Sep 9, 202650
Sep 8, 202650
Sep 7, 202650
npm weekly downloads

131−30 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026131
Dec 5, 2026113
Dec 4, 2026109
Dec 3, 2026113
Dec 2, 2026107
Dec 1, 2026105
Nov 30, 202696
Nov 29, 202692
Nov 28, 202681
Nov 27, 202680
Nov 26, 202691
Nov 25, 202691
Nov 24, 202689
Nov 23, 202688
Nov 22, 202684
Nov 21, 202690
Nov 20, 202688
Nov 19, 202664
Nov 18, 202683
Nov 17, 202694
Nov 16, 202698
Nov 15, 2026106
Nov 14, 2026110
Nov 13, 2026106
Nov 12, 2026122
Nov 11, 2026107
Nov 10, 2026100
Nov 9, 202697
Nov 8, 202687
Nov 7, 202675
Nov 6, 202659
Nov 5, 202645
Nov 4, 202642
Nov 3, 202644
Nov 2, 202663
Nov 1, 202689
Oct 31, 202699
Oct 30, 2026142
Oct 29, 2026133
Oct 28, 2026124
Oct 27, 2026121
Oct 26, 2026103
Oct 25, 202676
Oct 24, 202669
Oct 23, 202625
Oct 22, 202634
Oct 21, 202650
Oct 20, 202648
Oct 19, 202658
Oct 18, 202657
Oct 17, 202653
Oct 16, 202654
Oct 15, 202656
Oct 14, 202656
Oct 13, 202659
Oct 12, 202651
Oct 11, 202656
Oct 10, 202669
Oct 9, 202676
Oct 8, 202668
Oct 7, 202653
Oct 6, 202647
Oct 5, 202640
Oct 4, 202640
Oct 3, 202631
Oct 2, 202627
Oct 1, 202625
Sep 30, 202632
Sep 29, 202646
Sep 28, 202649
Sep 27, 202661
Sep 26, 202674
Sep 25, 202685
Sep 24, 202686
Sep 23, 202683
Sep 22, 202670
Sep 21, 202668
Sep 20, 202654
Sep 19, 202643
Sep 18, 202670
Sep 17, 2026101
Sep 16, 2026131
Sep 15, 2026136
Sep 14, 2026153
Sep 13, 2026169
Sep 12, 2026197
Sep 11, 2026196
Sep 10, 2026186
Sep 9, 2026182
Sep 8, 2026175
Sep 7, 2026161

Each point is npm's rolling 7-day download count.

Health Score

45/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1033487453-root.svg)](https://payloaddirectory.dev/plugins/1033487453-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1033487453-root"><img src="https://payloaddirectory.dev/badge/1033487453-root.svg" alt="Payload Directory"></a>
Updated Aug 26, 2025Created Aug 6, 2025Published Aug 26, 2025

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

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:

KeyTypeDescription
apiKey*string (required)A Google PageSpeed Insights API key.
debugbooleanA boolean that, when true, shows debug information and the hidden reports collection.
disabledbooleanA boolean that, when true, prevents the plugin from mounting the api endpoint in collection config.
generateFileNamefunction (GenerateFileNameFn)An optional function that is invoked to generate a filename for a PageSpeed Insights report object.
generateFilePrefixfunction (GenerateFilePrefixFn)An optional function that is invoked to generate a file prefix for a PageSpeed Insights report object if using a storage adapter.
overrideInsightsCollectionfunction (CollectionOverride)A function used to override the default PageSpeed Insights collection.
overrideReportsCollectionfunction (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

With custom access controls
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
      })
    }),
  ],
})
With storage adapter
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:

ParameterTypeDescription
reportPageSpeedReportObject | string | numberThe pagespeed report. This will be a document id if the insights document already has a report generated.
messagestringA 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

Similar plugins