Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.
AuthorSandro Wegmann, 10xMedia

How to use query presets in Payload

Community Guide
AuthorSandro Wegmann, 10xMedia

Query presets allows users to filter collection lists dynamically—without needing to hard-code anything in the config. This guide walks through what they are, how they differ from base list filters, and how to implement them with role-based access control.

Query presets vs baseListFilter

  • Base list filters are developer-defined and hard-coded for specific collections. They’re typically used for features like soft deletes:
  • Query presets are dynamic, user-created filters stored in the database. They’re created via the Payload admin UI and can be private, shared globally, or shared with specific users or roles.

Config options of Query presets

  • Limit usage of Query presents to certain users: Hardcoded in the config (only admins can create presets).
  • Choose whether a preset is private or shared: Dynamic, can be chosen in admin panel when creating a preset.
    • Default options (for every CRUD operation): Only me, everyone, specific users
    • Custom options (hardcoded in config) that user can select. For example, users with role 'editor' can see or update my present.

Enabling Query Presets

In our example collection config (e.g., companies), add:

1
export const Companies: CollectionConfig = {
2
slug: 'companies',
3
queryPresets: {
4
enabled: true, // We set this to true
5
},
6
fields: [
7
{ name: 'name', type: 'text' },
8
{ name: 'description', type: 'textarea' },
9
{ name: 'website', type: 'text' },
10
{ name: 'logo', type: 'upload', relationTo: 'media' },
11
{ name: 'active', type: 'checkbox' },
12
],
13
}

This enables users to create and manage presets directly in the admin panel.

Creating a Preset

  1. Open a collection (like companies) in the admin panel.
  2. Click the Filters button and add a condition (e.g., active equals true).
  3. Open the Presets menu (three dots) and click Create new.
  4. Name your preset (e.g., “Only active companies”).
  5. Choose whether it’s private, shared globally, or shared with specific users.
  6. Optionally customize visible columns before saving.

Controlling who can use or create presets

You can limit access via payload.config.ts.

For example:

1
queryPresets: {
2
enabled: true,
3
access: {
4
create: ({ req: { user } }) => user?.roles?.includes('admin'), // These roles have to be set in Users.ts
5
read: () => true,
6
update: ({ req: { user } }) => user?.roles?.includes('admin'),
7
delete: ({ req: { user } }) => user?.roles?.includes('admin'),
8
},
9
}

This restricts preset creation and management to users with the admin role.

Advanced sharing options

You can define custom share targets (like all editors) by extending the share config. Example:

1
queryPresets: {
2
enabled: true,
3
constraints: {
4
read: {
5
label: 'Specific Roles',
6
value: 'specificRoles',
7
fields: [
8
{
9
name: 'roles',
10
type: 'select',
11
hasMany: true,
12
options: [
13
{ label: 'Admin', value: 'admin' },
14
{ label: 'Editor', value: 'editor' },
15
],
16
},
17
],
18
access: ({ req: { user } }) => ({
19
'access.read.roles': {
20
in: user?.roles,
21
},
22
}),
23
},
24
},
25
},

In the UI, users can now choose to share with “All Editors” during preset creation, assuming access conditions are met.

Query presents ultimately gives users real control over their view of the data, while still giving developers full control over access and permissions.