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.

Customizing Views

Views are the individual pages that make up the Admin Panel, such as the Dashboard, List View, and Edit View. One of the most powerful ways to customize the Admin Panel is to create Custom Views. These are Custom Components that can either replace built-in views or be entirely new.

There are four types of views within the Admin Panel:

To swap in your own Custom View, first determine the scope that corresponds to what you are trying to accomplish, consult the list of available components, then author your React component(s) accordingly.

Configuration

Replacing Views

To customize views, use the admin.components.views property in your Payload Config. This is an object with keys for each view you want to customize. Each key corresponds to the view you want to customize.

The exact list of available keys depends on the scope of the view you are customizing, depending on whether it's a Root View, Collection View, or Global View. Regardless of the scope, the principles are the same.

Here is an example of how to swap out a built-in view:

1
import { buildConfig } from 'payload'
2
3
const config = buildConfig({
4
// ...
5
admin: {
6
components: {
7
views: {
8
dashboard: {
9
Component: '/path/to/MyCustomDashboard',
10
}
11
}
12
}
13
}
14
})

For more granular control, pass a configuration object instead. Payload exposes the following properties for each view:

Property

Description

Component *

Pass in the component path that should be rendered when a user navigates to this route.

path *

Any valid URL path or array of paths that path-to-regexp understands.

exact

Boolean. When true, will only match if the path matches the usePathname() exactly.

strict

When true, a path that has a trailing slash will only match a location.pathname with a trailing slash. This has no effect when there are additional URL segments in the pathname.

sensitive

When true, will match if the path is case sensitive.

meta

Page metadata overrides to apply to this view within the Admin Panel. More details.

* An asterisk denotes that a property is required.

Adding New Views

To add a new view to the Admin Panel, simply add your own key to the views object. This is true for all view scopes.

New views require at least the Component and path properties:

1
import { buildConfig } from 'payload'
2
3
const config = buildConfig({
4
// ...
5
admin: {
6
components: {
7
views: {
8
myCustomView: {
9
Component: '/path/to/MyCustomView#MyCustomViewComponent',
10
path: '/my-custom-view',
11
},
12
},
13
},
14
},
15
})

Building Custom Views

Custom Views are simply Custom Components rendered at the page-level. Custom Views can either replace existing views or add entirely new ones. The process is generally the same regardless of the type of view you are customizing.

To understand how to build Custom Views, first review the Building Custom Components guide. Once you have a Custom Component ready, you can use it as a Custom View.

1
import type { CollectionConfig } from 'payload'
2
3
export const MyCollectionConfig: CollectionConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
edit: {
9
Component: '/path/to/MyCustomView'
10
}
11
},
12
},
13
},
14
}

Default Props

Your Custom Views will be provided with the following props:

Prop

Description

initPageResult

An object containing req, payload, permissions, etc.

clientConfig

The Client Config object. More details.

importMap

The import map object.

params

An object containing the Dynamic Route Parameters.

searchParams

An object containing the Search Parameters.

doc

The document being edited. Only available in Document Views. More details.

i18n

The i18n object.

payload

The Payload class.

Here is an example of a Custom View component:

1
import type { AdminViewServerProps } from 'payload'
2
3
import { Gutter } from '@payloadcms/ui'
4
import React from 'react'
5
6
export function MyCustomView(props: AdminViewServerProps) {
7
return (
8
<Gutter>
9
<h1>Custom Default Root View</h1>
10
<p>This view uses the Default Template.</p>
11
</Gutter>
12
)
13
}

View Templates

Your Custom Root Views can optionally use one of the templates that Payload provides. The most common of these is the Default Template which provides the basic layout and navigation.

Here is an example of how to use the Default Template in your Custom View:

1
import type { AdminViewServerProps } from 'payload'
2
3
import { DefaultTemplate } from '@payloadcms/next/templates'
4
import { Gutter } from '@payloadcms/ui'
5
import React from 'react'
6
7
export function MyCustomView({
8
initPageResult,
9
params,
10
searchParams,
11
}: AdminViewServerProps) {
12
return (
13
<DefaultTemplate
14
i18n={initPageResult.req.i18n}
15
locale={initPageResult.locale}
16
params={params}
17
payload={initPageResult.req.payload}
18
permissions={initPageResult.permissions}
19
searchParams={searchParams}
20
user={initPageResult.req.user || undefined}
21
visibleEntities={initPageResult.visibleEntities}
22
>
23
<Gutter>
24
<h1>Custom Default Root View</h1>
25
<p>This view uses the Default Template.</p>
26
</Gutter>
27
</DefaultTemplate>
28
)
29
}

Securing Custom Views

All Custom Views are public by default. It's up to you to secure your custom views. If your view requires a user to be logged in or to have certain access rights, you should handle that within your view component yourself.

Here is how you might secure a Custom View:

1
import type { AdminViewServerProps } from 'payload'
2
3
import { Gutter } from '@payloadcms/ui'
4
import React from 'react'
5
6
export function MyCustomView({
7
initPageResult
8
}: AdminViewServerProps) {
9
const {
10
req: {
11
user
12
}
13
} = initPageResult
14
15
if (!user) {
16
return <p>You must be logged in to view this page.</p>
17
}
18
19
return (
20
<Gutter>
21
<h1>Custom Default Root View</h1>
22
<p>This view uses the Default Template.</p>
23
</Gutter>
24
)
25
}

Root Views

Root Views are the main views of the Admin Panel. These are views that are scoped directly under the /admin route, such as the Dashboard or Account views.

To swap out Root Views with your own, or to create entirely new ones, use the admin.components.views property at the root of your Payload Config:

1
import { buildConfig } from 'payload'
2
3
const config = buildConfig({
4
// ...
5
admin: {
6
components: {
7
views: {
8
dashboard: {
9
Component: '/path/to/Dashboard',
10
}
11
// Other options include:
12
// - account
13
// - [key: string]
14
// See below for more details
15
},
16
},
17
},
18
})

For details on how to build Custom Views, including all available props, see Building Custom Views.

The following options are available:

Property

Description

account

The Account view is used to show the currently logged in user's Account page.

dashboard

The main landing page of the Admin Panel.

[key]

Any other key can be used to add a completely new Root View. More details.

Collection Views

Collection Views are views that are scoped under the /collections route, such as the Collection List and Document Edit views.

To swap out Collection Views with your own, or to create entirely new ones, use the admin.components.views property of your Collection Config:

1
import type { CollectionConfig } from 'payload'
2
3
export const MyCollectionConfig: CollectionConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
edit: {
9
default: {
10
Component: '/path/to/MyCustomCollectionView',
11
}
12
}
13
// Other options include:
14
// - list
15
// - [key: string]
16
// See below for more details
17
},
18
},
19
},
20
}

The following options are available:

Property

Description

edit

The Edit View corresponds to a single Document for any given Collection and consists of various nested views. More details.

list

The List View is used to show a list of Documents for any given Collection. More details.

[key]

Any other key can be used to add a completely new Collection View. More details.

For details on how to build Custom Views, including all available props, see Building Custom Views.

Global Views

Global Views are views that are scoped under the /globals route, such as the Edit View.

To swap out Global Views with your own or create entirely new ones, use the admin.components.views property in your Global Config:

1
import type { SanitizedGlobalConfig } from 'payload'
2
3
export const MyGlobalConfig: SanitizedGlobalConfig = {
4
// ...
5
admin: {
6
components: {
7
views: {
8
edit: {
9
default: {
10
Component: '/path/to/MyCustomGlobalView',
11
}
12
}
13
// Other options include:
14
// - [key: string]
15
// See below for more details
16
},
17
},
18
},
19
}

The following options are available:

Property

Description

edit

The Edit View represents a single Document for any given Global and consists of various nested views. More details.

[key]

Any other key can be used to add a completely new Global View. More details.

For details on how to build Custom Views, including all available props, see Building Custom Views.

Next

Document Views