Integrates the Google PageSpeed Insights API into Payload. Creating an entry with a URL in the added collection fetches a report and saves it, showing Performance, Accessibility, SEO and Best Practices metrics in the admin panel. Requires a PageSpeed Insights API key and works with Payload 3.50 or later.
A Payload CMS plugin that integrates PageSpeed Insights into your project.
Installation
npm i payload-plugin-pagespeed51
Stars
1
Forks
0
Open Issues
1 years ago
Last Updated
0
Weekly Downloads
v0.2.1
npm Version
222.0 KB
Unpacked Size
0
Dependencies
Trends appear after 7 days of data. Daily snapshots have not started yet.
Trends appear after 7 days of data. Daily snapshots have not started yet.
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1033487453-root)<a href="https://payloaddirectory.dev/plugins/1033487453-root"><img src="https://payloaddirectory.dev/badge/1033487453-root.svg" alt="Payload Directory"></a>README
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.
payload-plugin-pagespeed-demo.webm
pnpm add payload-plugin-pagespeed
[!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.
PageSpeed Insights collection in the Payload admin.URL.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
readandcreateaccess for the PageSpeed Insights collection. In addition, this plugin sets theupdateaccess control on the PageSpeed Insights collection tofalse. An example below shows customizing access controls and other collection configs.
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
}),
],
})
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.
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.
If no doc id is provided, then the url query parameter is required.
GET /api/pagespeed-insights/report?url=https://payloadcms.com
GET /api/pagespeed-insights/68aa352d42f08695dd833412/report
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. |
Contributions are welcome!
If you’d like to improve this plugin, feel free to open an issue or PR.
MIT © 2025 saikhon.dev
payload plugin ab
A/B testing for Payload pages with admin-managed variants and edge traffic routing in Next.js middleware
600/wk29v3
payload sales reports
Sales totals by period, product and customer for Payload ecommerce, exposed as functions and read-only endpoints
570/wk1v3
payload plugin analytics
GA4-backed analytics dashboard inside the Payload admin with client-side tracking for Next.js front ends
470/wk29v3
payload plugin ga4 ecommerce
Google Analytics 4 dashboards and per-record analytics tabs inside the Payload admin panel
430/wk10v3
payload dashboard analytics
Show Plausible or Google Analytics data as chart and report widgets in the Payload admin dashboard
340/wk185v1
sitemap
Chunked, lazily cached XML sitemaps with hook-driven invalidation and robots.txt helpers
6123/wk15v3