Adds a slug, a parent and a stored path to the collections you choose, so a site can find a document at a path with one indexed query. Moving or renaming a document updates everything below it, and each path belongs to one document across collections. It works with MongoDB, Postgres and SQLite and requires Payload 4.0.0-beta.12 or later.
Stored URL paths for Payload 4 pages and posts. Editors pick a parent and a slug, and a site finds the document at a path in one indexed query, in any language.
Installation
npm i @payloadpack/path10
Stars
0
Forks
0
Open Issues
1 weeks ago
Last Updated
270
Weekly Downloads
v0.4.1
npm Version
171.6 KB
Unpacked Size
0
Dependencies
10+10 since Oct 18
| Date | Stars |
|---|---|
| Dec 6, 2026 | 10 |
| Dec 5, 2026 | 10 |
| Dec 4, 2026 | 10 |
| Dec 3, 2026 | 10 |
| Dec 2, 2026 | 10 |
| Dec 1, 2026 | 10 |
| Nov 30, 2026 | 10 |
| Nov 29, 2026 | 10 |
| Nov 28, 2026 | 9 |
| Nov 27, 2026 | 9 |
| Nov 26, 2026 | 9 |
| Nov 25, 2026 | 9 |
| Nov 24, 2026 | 9 |
| Nov 23, 2026 | 9 |
| Nov 22, 2026 | 9 |
| Nov 21, 2026 | 9 |
| Nov 20, 2026 | 9 |
| Nov 19, 2026 | 9 |
| Nov 18, 2026 | 10 |
| Nov 17, 2026 | 9 |
| Nov 16, 2026 | 8 |
| Nov 15, 2026 | 8 |
| Nov 14, 2026 | 8 |
| Nov 13, 2026 | 8 |
| Nov 12, 2026 | 6 |
| Nov 11, 2026 | 5 |
| Nov 10, 2026 | 3 |
| Nov 9, 2026 | 3 |
| 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 | 0 |
| Oct 26, 2026 | 0 |
| Oct 25, 2026 | 0 |
| Oct 24, 2026 | 0 |
| Oct 23, 2026 | 0 |
| Oct 22, 2026 | 0 |
| Oct 21, 2026 | 0 |
| Oct 20, 2026 | 0 |
| Oct 19, 2026 | 0 |
| Oct 18, 2026 | 0 |
Shared by 3 plugins in payloadpack/plugins.
331+331 since Nov 20
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 331 |
| Dec 5, 2026 | 718 |
| Dec 4, 2026 | 1,030 |
| Dec 3, 2026 | 1,050 |
| Dec 2, 2026 | 1,067 |
| Dec 1, 2026 | 1,167 |
| Nov 30, 2026 | 1,262 |
| Nov 29, 2026 | 1,819 |
| Nov 28, 2026 | 1,782 |
| Nov 27, 2026 | 1,444 |
| Nov 26, 2026 | 1,409 |
| Nov 25, 2026 | 1,362 |
| Nov 24, 2026 | 1,165 |
| Nov 23, 2026 | 1,011 |
| Nov 22, 2026 | 363 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
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/1428386015-path)<a href="https://payloaddirectory.dev/plugins/1428386015-path"><img src="https://payloaddirectory.dev/badge/1428386015-path.svg" alt="Payload Directory"></a>README
Stored URL paths for Payload 4 pages and posts.
Editors pick a parent and a slug, and your site finds the document at a path in one indexed query.
Documentation · Installation · Changelog · Contributing
/blog/, and the slugs your site keeps for itselfbun add @payloadpack/path
import { pathPlugin } from '@payloadpack/path'
export default buildConfig({
plugins: [pathPlugin({ collections: ['pages', 'posts'] })]
})
Pages and posts now have a slug, a parent and their path in the sidebar. A page sits below a page and a post below a post. On Postgres or SQLite, create a migration for the new fields.
Then your site's catch-all route asks for the document at a path:
import { findByPath } from '@payloadpack/path'
const found = await findByPath({ path: '/about/team', payload })
// { collection: 'pages', document: { id, title, path: '/about/team', ... } }, or null
The plugin works with database transactions and without them, on MongoDB, Postgres and SQLite.
With transactions, a save, move or delete that fails leaves everything as it was. Without them, which is SQLite's default, a move that stops halfway leaves some documents at their old paths, and backfillPaths puts them right.
| Key | What it sets | Default |
|---|---|---|
collections | The collections whose documents get a path, each by its slug or as { slug, basePath, parent, localized }, beside the ones wrapped in withPath | none |
rootSlug | The slug that makes a top-level document the home page at / | home |
reservedSegments | Segments your site serves itself, at the root or at any depth, as a list or each with why | Payload's admin and API routes |
slugify | What makes a slug from a title and from what an editor types, as in Payload's own slug field | Accents off Latin letters, other scripts kept |
onPathsChanged | A function that hears which paths changed, so you can purge your cache and keep your redirects | none |
A collection given as { slug: 'posts', basePath: '/blog' } puts its top-level documents below /blog, as in /blog/hello-world. The base path is optional, and a path still belongs to one document across all your collections.
Each collection decides where a document's parent comes from:
parent: false its documents have no parent, so a post's path is /blog, a slash and its slug.hierarchy on the collection, the plugin uses Payload's parent and you keep Payload's tree in the admin. There is nothing to set in the plugin for it.A collection also takes slugField and parentField, which set Payload's own field options such as access on the plugin's fields, for example so that only a save in the default locale changes a slug.
A collection can also keep these settings in its own config, wrapped in withPath, which takes the same keys without slug. The plugin still has to be in plugins, and it adds the fields when it runs:
import { pathPlugin, withPath } from '@payloadpack/path'
const posts = withPath({ slug: 'posts', fields: [] }, { basePath: '/blog', parent: false })
export default buildConfig({
collections: [posts],
plugins: [pathPlugin()]
})
A relationship field in a block, a global or a collection is built when its file is imported, before the config exists, so it can't ask which collections have a path. Make it with pathRelationshipField, and pathPlugin() fills in the collections with a path when it runs:
import { pathRelationshipField } from '@payloadpack/path'
// Every collection with a path
pathRelationshipField({ name: 'doc', label: 'Document', required: true })
// Only these, each of which must have a path
pathRelationshipField({ name: 'doc', relationTo: ['pages'] })
It takes everything a relationship field takes except type. A relationTo you give is the field's from the start, in its order, and wherever the plugin finds the field it stops Payload when that list is empty or names a collection without a path. relationTo is always a list, so a value is stored as { relationTo, value } even with one collection, and offering a second one later needs no migration. The plugin finds the field anywhere in the config it gets. A field Lexical builds later, such as one in the fields of LinkFeature, isn't there yet, so give it relationTo: getPathCollectionSlugs(config) from the config that function gets, as the docs show.
getPathCollectionSlugs(config) lists the collections that get a path, in either way, for a plugin after pathPlugin(), a field's config function or payload.config, such as the fields of Lexical's LinkFeature.
Every option and every message an editor can meet are in the docs.
With localization, a collection's documents keep one slug and one path for every language, so a site that gets localization later keeps the paths it has. A collection given with localized: true has a path per locale instead, made from each locale's own slug, or from the slug it falls back to when it has none:
pathPlugin({ collections: [{ slug: 'pages', localized: true }] })
The locale is never part of the path, so your routes decide where it goes:
const found = await findByPath({ locale, path: `/${(segments ?? []).join('/')}`, payload })
With a path per locale, the same path may show different documents in different languages, and each language is published on its own. To link to a document in the other languages, findPaths({ collection, id, payload }) gives its path in each locale it is published in, and findByPath gives the same paths with the document when you pass paths: true.
A lookup is one indexed query per collection, and none for a path your site reserves.
The median and 95th percentile (p95) of each, on a database with 100,000 documents. Run on 2026-11-20, on Apple M3 Max with 128 GB of memory and Node 26.13.1.
Without localization:
| Operation | MongoDB | Postgres | SQLite |
|---|---|---|---|
| Lookup by path | 0.3 ms (p95 0.5 ms) | 0.5 ms (p95 0.7 ms) | 0.3 ms (p95 0.4 ms) |
| Autosave | 9.1 ms (p95 11 ms) | 4.6 ms (p95 5.4 ms) | 48 ms (p95 55 ms) |
| Publish, same slug | 9.2 ms (p95 15 ms) | 4.7 ms (p95 5.7 ms) | 29 ms (p95 34 ms) |
| Publish, new slug | 10 ms (p95 12 ms) | 6.7 ms (p95 9 ms) | 29 ms (p95 37 ms) |
| Move of 1,000 pages | 101 ms (p95 112 ms) | 185 ms (p95 196 ms) | 112 ms (p95 127 ms) |
With localization (two locales):
| Operation | MongoDB | Postgres | SQLite |
|---|---|---|---|
| Lookup by path | 0.2 ms (p95 0.4 ms) | 0.6 ms (p95 0.8 ms) | 0.3 ms (p95 0.4 ms) |
| Autosave | 8.3 ms (p95 9.9 ms) | 5.4 ms (p95 6.3 ms) | 44 ms (p95 50 ms) |
| Publish, same slug | 8.7 ms (p95 10 ms) | 7.2 ms (p95 11 ms) | 26 ms (p95 30 ms) |
| Publish, new slug | 11 ms (p95 15 ms) | 8.2 ms (p95 14 ms) | 26 ms (p95 30 ms) |
| Move of 1,000 pages | 126 ms (p95 135 ms) | 352 ms (p95 370 ms) | 162 ms (p95 519 ms) |
The speed page has what was measured, and how to run the benchmark yourself.
Payload 4.0.0-beta.12 or later, with MongoDB, Postgres or SQLite.
Use it in any project, including client work you charge for and products you sell. What you can't do is offer the plugin, or a copy or fork of it, to others as a competing plugin, paid or free. The terms are the PolyForm Perimeter License 1.0.1.
Tags
payload slug
Slug field with Auto/Manual modes, nested source paths, localization and enforced uniqueness
802.4k/wk0v3
payload page tree
Folder-based hierarchical URL slugs with a visual page tree in the Payload admin
81536/wk19v3
payload redirect
Automatic and manual 301/302 redirect rules stored in a native Payload collection, with cycle validation
793.4k/wk0v3
redirects
Editor-managed redirects for Payload 4 with indexed lookups, regex support and move-based redirect suggestions
72187/wk10v4
nested docs
Official plugin for nesting Payload documents inside one another
100151.9k/wk46.1kv3 v4
localized slugs
Copies localized slug and full path values into a per-locale localizedSlugs field for multi-language Payload sites
7881/wk9v3