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.

Custom Admin Panel Location

Payload is flexible about where your Admin Panel lives within your Next.js application. You can customize routes, move folders, and organize your project structure to match your application's needs.

Common Use Cases

  • Custom admin routes - Change /admin to /dashboard, /cms, etc.
  • Nested admin panels - Place Payload at /admin/content alongside custom admin routes
  • Multiple admin interfaces - Organize Payload and custom dashboards together
  • Organizational preferences - Match your team's folder structure conventions

Understanding the Payload Folder Structure

By default, Payload creates this structure in your Next.js app:

1
app/ (or src/app/)
2
├── (payload)/
3
│ ├── admin/
4
│ │ ├── [[...segments]]/
5
│ │ │ ├── not-found.tsx
6
│ │ │ └── page.tsx
7
│ │ └── importMap.js
8
│ ├── api/
9
│ │ └── [...slug]/
10
│ │ └── route.ts
11
│ ├── custom.scss
12
│ └── layout.tsx
  • (payload)/ - Parent folder containing all Payload-related routes
  • admin/ - Admin Panel UI routes
  • api/ - REST API routes
  • layout.tsx - Root layout that imports the import map
  • importMap.js - Auto-generated file mapping component paths (regenerated on startup)

Scenario 1: Simple Route Change

To change the admin route from /admin to /dashboard:

1. Update your Payload Config:

1
import { buildConfig } from 'payload'
2
3
export default buildConfig({
4
// ...
5
routes: {
6
admin: '/dashboard', // Changed from '/admin'
7
},
8
})

2. Move the folder:

1
# Move the admin folder
2
mv app/(payload)/admin app/(payload)/dashboard

3. Update the import path in layout.tsx:

Edit app/(payload)/layout.tsx and update the import map reference to match the new folder name:

1
// Before
2
import { importMap } from './admin/importMap.js'
3
4
// After
5
import { importMap } from './dashboard/importMap.js'

4. Restart your dev server

Payload will now be available at /dashboard.

Scenario 2: Moving the Entire Payload Folder (Admin Panel and API)

To move both the Payload Admin Panel and API under a custom path, you move the entire (payload) folder. This example places everything under /admin/content.

1. Update your Payload Config with all routes and import map settings:

1
import { buildConfig } from 'payload'
2
import path from 'path'
3
import { fileURLToPath } from 'url'
4
5
const filename = fileURLToPath(import.meta.url)
6
const dirname = path.dirname(filename)
7
8
export default buildConfig({
9
// ...
10
routes: {
11
admin: '/admin/content/admin',
12
api: '/admin/content/api',
13
graphQL: '/admin/content/api/graphql',
14
graphQLPlayground: '/admin/content/api/graphql-playground',
15
},
16
admin: {
17
importMap: {
18
baseDir: path.resolve(dirname, './src/app/admin/content/(payload)'),
19
importMapFile: path.resolve(
20
dirname,
21
'./src/app/admin/content/(payload)/admin/importMap.js',
22
),
23
},
24
},
25
})

2. Move the (payload) folder:

1
# Create the new directory structure
2
mkdir -p app/admin/content
3
4
# Move the entire (payload) folder
5
mv app/(payload) app/admin/content/(payload)

3. Update the import path in layout.tsx:

Edit app/admin/content/(payload)/layout.tsx:

1
// Change this import path to match your new structure
2
import { importMap } from './admin/importMap.js'

The import path should be relative from layout.tsx to importMap.js. In this case, it remains './admin/importMap.js'.

4. Regenerate the import map:

1
pnpm payload generate:importmap

Your Payload admin is now at /admin/content/admin and the API at /admin/content/api.

Scenario 3: Multiple Admin Dashboards

If you want both Payload and custom admin routes under /admin:

Folder Structure:

1
app/
2
├── admin/
3
│ ├── content/ # Payload admin
4
│ │ └── (payload)/
5
│ │ ├── admin/
6
│ │ ├── api/
7
│ │ └── layout.tsx
8
│ ├── platform/ # Your custom admin
9
│ │ ├── dashboard/
10
│ │ │ └── page.tsx
11
│ │ └── layout.tsx
12
│ └── page.tsx # Choose between admins

Configuration:

1
export default buildConfig({
2
routes: {
3
admin: '/admin/content',
4
api: '/admin/content/api',
5
graphQL: '/admin/content/api/graphql',
6
graphQLPlayground: '/admin/content/api/graphql-playground',
7
},
8
admin: {
9
importMap: {
10
baseDir: path.resolve(dirname, './src/app/admin/content/(payload)'),
11
importMapFile: path.resolve(
12
dirname,
13
'./src/app/admin/content/(payload)/admin/importMap.js',
14
),
15
},
16
},
17
})

Understanding Auto-Generated Files

Not all files in the (payload) folder are auto-generated. Here's what you need to know:

File

Auto-Generated?

Safe to Edit?

When Regenerated?

Notes

layout.tsx

No

Yes

Never

Created once during setup. Safe to modify import paths.

admin/importMap.js

Yes

No

Startup, HMR, manual command

Always regenerated. Configure via admin.importMap instead.

admin/[[...segments]]/page.tsx

No

Rarely needed

Never

Part of template. Usually no need to edit.

admin/[[...segments]]/not-found.tsx

No

Rarely needed

Never

Part of template. Usually no need to edit.

api/[...slug]/route.ts

No

Rarely needed

Never

Part of template. Usually no need to edit.

custom.scss

No

Yes

Never

Intended for your custom styles.

About the "DO NOT MODIFY" Warning

You may see this warning in layout.tsx:

1
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
2
/* DO NOT MODIFY IT BECAUSE IT COULD BE REWRITTEN AT ANY TIME. */

This warning is misleading. The file was generated during initial project setup by create-payload-app, but it is never regenerated by Payload. It is completely safe to modify this file, especially when customizing your folder structure.

Editing layout.tsx Safely

When you move the Payload folder, you'll need to update the import path in layout.tsx:

1
// app/admin/content/(payload)/layout.tsx
2
import { importMap } from './admin/importMap.js' // Update this path as needed

What you can safely edit:

  • Import map path (required when moving folders)
  • Custom imports for additional functionality
  • Custom SCSS imports
  • Server function logic (advanced use cases)

What you should NOT edit:

  • The core RootLayout usage (required for Payload)
  • The serverFunction pattern (required for Payload to work)
  • The import map prop to RootLayout

Import Map Regeneration

The importMap.js file is automatically regenerated in these scenarios:

  • Application startup - Every time you start your dev server or production build
  • Hot Module Replacement (HMR) - When you save changes to component files in development
  • Manual generation - When you run pnpm payload generate:importmap

The import map is never regenerated during:

  • Normal runtime (only at startup)
  • After the production build completes

Troubleshooting

Import map not found error

If you see an error about the import map not being found:

  1. Verify admin.importMap.importMapFile points to the correct location
  2. Run pnpm payload generate:importmap manually
  3. Check that the path is absolute, not relative

Layout.tsx import error

If you see an import error in layout.tsx:

  1. Verify the import path is relative from layout.tsx to importMap.js
  2. Use ./admin/importMap.js if importMap is in a sibling admin folder
  3. Use ./importMap.js if you moved importMap to the same folder as layout

Admin panel 404 error

If the admin panel returns 404:

  1. Verify routes.admin matches your actual folder structure
  2. Ensure you moved the entire (payload) folder, not just admin
  3. Check that Next.js is recognizing your new routes

Components not loading

If custom components aren't loading:

  1. Verify admin.importMap.baseDir is correct
  2. Regenerate the import map: pnpm payload generate:importmap
  3. Check component paths in your config are relative to baseDir

Additional Resources

Was this page helpful?

Next

Document Locking