Skip to content

Introduction

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.

@payloadpack/path is a Payload plugin. It gives the documents of the collections you name a slug and a stored path, such as /about/team, and keeps every path right while editors rename, move, publish and delete.

Your site then needs one call to know what a URL shows, instead of walking the page tree on each request.

A document sits below a parent of its own collection, held in the plugin’s own parent field or in Payload’s hierarchy, and a collection such as posts can go without parents. You pick per collection.

A stored path

The parent’s path, a slash and the slug, below an optional base path such as /blog, saved on the document and indexed.

One document per path

Across all your collections, drafts too. An editor who picks a path in use is told which document is at it.

Branches that move along

Rename or move a page or a post, and every document below it follows, drafts included.

A home page and reserved slugs

The top-level page named home answers /, and your site keeps /admin and /api for itself.

A path per language

A collection keeps one path for every locale, or has one per locale when you ask for it, and the locale stays out of it.

One query per lookup

findByPath asks each collection once, on its index, and asks nothing for a reserved path.

Package or database Version or setup
payload 4.0.0-beta.10 or later
MongoDB @payloadcms/db-mongodb
Postgres @payloadcms/db-postgres
SQLite @payloadcms/db-sqlite

The plugin works with database transactions and without them. See Installation.