Adds computed readingTime and wordCount number fields to configured collections and fills them in a beforeChange hook, so values are stored with the document. It walks the Lexical state, including nested block fields, and supports per-locale words-per-minute plus character counting for CJK locales. Requires Payload 3 and a Lexical rich-text field on each collection.
Computed reading time and word count for Payload CMS Lexical content
Installation
npm i payload-plugin-reading-time1
Stars
0
Forks
0
Open Issues
6 months ago
Last Updated
117
Weekly Downloads
v1.0.0
npm Version
70.8 KB
Unpacked Size
0
Dependencies
10 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 1 |
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
105+7 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 105 |
| Dec 5, 2026 | 94 |
| Dec 4, 2026 | 90 |
| Dec 3, 2026 | 22 |
| Dec 2, 2026 | 14 |
| Dec 1, 2026 | 18 |
| Nov 30, 2026 | 18 |
| Nov 29, 2026 | 15 |
| Nov 28, 2026 | 12 |
| Nov 27, 2026 | 12 |
| Nov 26, 2026 | 15 |
| Nov 25, 2026 | 19 |
| Nov 24, 2026 | 11 |
| Nov 23, 2026 | 11 |
| Nov 22, 2026 | 13 |
| Nov 21, 2026 | 20 |
| Nov 20, 2026 | 50 |
| Nov 19, 2026 | 71 |
| Nov 18, 2026 | 87 |
| Nov 17, 2026 | 105 |
| Nov 16, 2026 | 108 |
| Nov 15, 2026 | 113 |
| Nov 14, 2026 | 113 |
| Nov 13, 2026 | 101 |
| Nov 12, 2026 | 87 |
| Nov 11, 2026 | 80 |
| Nov 10, 2026 | 107 |
| Nov 9, 2026 | 109 |
| Nov 8, 2026 | 117 |
| Nov 7, 2026 | 141 |
| Nov 6, 2026 | 168 |
| Nov 5, 2026 | 161 |
| Nov 4, 2026 | 195 |
| Nov 3, 2026 | 154 |
| Nov 2, 2026 | 154 |
| Nov 1, 2026 | 142 |
| Oct 31, 2026 | 113 |
| Oct 30, 2026 | 73 |
| Oct 29, 2026 | 70 |
| Oct 28, 2026 | 22 |
| Oct 27, 2026 | 28 |
| Oct 26, 2026 | 28 |
| Oct 25, 2026 | 27 |
| Oct 24, 2026 | 30 |
| Oct 23, 2026 | 23 |
| Oct 22, 2026 | 35 |
| Oct 21, 2026 | 50 |
| Oct 20, 2026 | 45 |
| Oct 19, 2026 | 44 |
| Oct 18, 2026 | 47 |
| Oct 17, 2026 | 47 |
| Oct 16, 2026 | 51 |
| Oct 15, 2026 | 48 |
| Oct 14, 2026 | 50 |
| Oct 13, 2026 | 66 |
| Oct 12, 2026 | 96 |
| Oct 11, 2026 | 95 |
| Oct 10, 2026 | 93 |
| Oct 9, 2026 | 107 |
| Oct 8, 2026 | 134 |
| Oct 7, 2026 | 141 |
| Oct 6, 2026 | 123 |
| Oct 5, 2026 | 94 |
| Oct 4, 2026 | 95 |
| Oct 3, 2026 | 95 |
| Oct 2, 2026 | 103 |
| Oct 1, 2026 | 100 |
| Sep 30, 2026 | 90 |
| Sep 29, 2026 | 91 |
| Sep 28, 2026 | 89 |
| Sep 27, 2026 | 94 |
| Sep 26, 2026 | 96 |
| Sep 25, 2026 | 78 |
| Sep 24, 2026 | 62 |
| Sep 23, 2026 | 96 |
| Sep 22, 2026 | 96 |
| Sep 21, 2026 | 96 |
| Sep 20, 2026 | 95 |
| Sep 19, 2026 | 111 |
| Sep 18, 2026 | 116 |
| Sep 17, 2026 | 107 |
| Sep 16, 2026 | 86 |
| Sep 15, 2026 | 97 |
| Sep 14, 2026 | 109 |
| Sep 13, 2026 | 104 |
| Sep 12, 2026 | 87 |
| Sep 11, 2026 | 79 |
| Sep 10, 2026 | 97 |
| Sep 9, 2026 | 100 |
| Sep 8, 2026 | 104 |
| Sep 7, 2026 | 98 |
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/1250710535-root)<a href="https://payloaddirectory.dev/plugins/1250710535-root"><img src="https://payloaddirectory.dev/badge/1250710535-root.svg" alt="Payload Directory"></a>README
Computed reading time and word count for Payload CMS Lexical content.
getTextContent() shortcut quietly loses text).beforeChange, so reading time and word count are persisted fields — fast to query, no per-render cost.readingTime — number (minutes), sidebarwordCount — number, sidebarfields, picks up nested rich-text states)^3.84.0pnpm add payload-plugin-reading-time
import { payloadReadingTime } from 'payload-plugin-reading-time'
export default buildConfig({
plugins: [
payloadReadingTime({
collections: {
// Use defaults: rich-text field is `content`, adds `readingTime`
// and `wordCount` fields.
posts: true,
// Override per-collection:
docs: {
richTextField: 'body',
wordCountField: false, // skip word count for this collection
},
},
// Optional — defaults below.
defaultWordsPerMinute: 250,
wordsPerMinute: { 'en-US': 280, zh: 500 },
characterBasedLocales: ['zh', 'ja', 'ko'],
}),
],
})
The plugin appends fields to your collection (it never replaces existing fields with the same name, so you can pre-declare them if you want to customize labels).
| Option | Type | Default | Description |
|---|---|---|---|
collections | Record<string, true | {…}> | — | Map of slug → per-collection config. |
defaultWordsPerMinute | number | 250 | Used when no per-locale value matches. |
wordsPerMinute | Record<string, number> | {} | Words-per-minute per locale or language prefix. |
characterBasedLocales | string[] | ['zh','ja','ko'] | Locales that count characters instead of words. |
disabled | boolean | false | Skip hook wiring but keep schema additions. |
Pass true to use defaults, or an object with any of:
| Option | Type | Default | Description |
|---|---|---|---|
richTextField | string | 'content' | Dot-path to the Lexical rich-text field used as input. |
readingTimeField | string | false | 'readingTime' | Name of the field to store reading time. Pass false to skip. |
wordCountField | string | false | 'wordCount' | Name of the field to store word count. Pass false to skip. |
admin | object | see below | Admin-UI placement for readingTime and wordCount. See Admin placement. |
If a field with the chosen name already exists on the collection, the plugin reuses it — handy when you want a custom label, description, or admin position.
admin controls where the two computed fields render in the document view.
| Option | Type | Default | Description |
|---|---|---|---|
position | 'main' | 'sidebar' | 'sidebar' | Render the fields in the sidebar (compact, default) or inline at the bottom of the main form. |
layout | 'stacked' | 'row' | 'stacked' | stacked keeps each field on its own line; row puts both side-by-side at 50% width inside a Row Field. |
payloadReadingTime({
collections: {
// Default: each on its own line in the sidebar.
posts: true,
// Both fields in one row, in the main form.
docs: {
richTextField: 'body',
admin: { position: 'main', layout: 'row' },
},
// Sidebar, side-by-side.
notes: {
admin: { position: 'sidebar', layout: 'row' },
},
},
})
Notes:
layout: 'row' is only applied when both readingTimeField and wordCountField are enabled and neither already exists on the collection. Otherwise the layout silently falls back to stacked.admin config) and never wraps it in a row.| Import | Description |
|---|---|
payload-plugin-reading-time | payloadReadingTime plugin, types, and pure helpers (walkLexical, computeReadingTime, countWords, resolveWordsPerMinute, isCharacterBased, createComputeReadingTimeHook). |
payload-plugin-reading-time/rsc | Server-component-safe re-exports of the walker and computation helpers. |
beforeChange hook reads the configured rich-text field from data (falling back to originalDoc).fields property — nested Lexical states inside blocks contribute text to the parent document.The plugin's source lives in src/ and is consumed by the local app in dev/ under its published name (payload-plugin-reading-time, payload-plugin-reading-time/rsc) via dev/tsconfig.json paths and the next.config.mjs alias map — no link:. self-dependency required.
Run pnpm dev for the local Payload admin (defaults to http://localhost:3000), pnpm test:unit for the Vitest unit suite, pnpm test:int for the integration suite (in-memory MongoDB), and pnpm test:e2e for the Playwright suite.
MIT
payload plugin json form builder
Edit a Payload json field as real admin fields, with the form shape built in the admin panel
72441/wk37v3
link field
Link field and Lexical link feature supporting internal document and custom URL links
6346/wk0v4
heading field
Field wrapper that lets editors choose the h1–h6 tag for text, textarea, or rich text headings
62156/wk16v3
payload plugin comments
Inline comment threads on Lexical rich text with a sidebar panel, in English and French
589/wk0v3
fullscreen editor
Fullscreen mode for the Lexical rich text editor in the Payload admin
88347/wk115v4
payload fields
Field factories and admin components for Unicode slugs, Jalali dates, integer money and Iranian identity data
75230/wk3v3