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.
/admin to /dashboard, /cms, etc./admin/content alongside custom admin routesBy default, Payload creates this structure in your Next.js app:
(payload)/ - Parent folder containing all Payload-related routesadmin/ - Admin Panel UI routesapi/ - REST API routeslayout.tsx - Root layout that imports the import mapimportMap.js - Auto-generated file mapping component paths (regenerated on startup)To change the admin route from /admin to /dashboard:
1. Update your Payload Config:
2. Move the folder:
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:
4. Restart your dev server
Payload will now be available at /dashboard.
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:
2. Move the (payload) folder:
3. Update the import path in layout.tsx:
Edit app/admin/content/(payload)/layout.tsx:
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:
Your Payload admin is now at /admin/content/admin and the API at /admin/content/api.
If you want both Payload and custom admin routes under /admin:
Folder Structure:
Configuration:
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 |
|---|---|---|---|---|
| No | Yes | Never | Created once during setup. Safe to modify import paths. |
| Yes | No | Startup, HMR, manual command | Always regenerated. Configure via |
| No | Rarely needed | Never | Part of template. Usually no need to edit. |
| No | Rarely needed | Never | Part of template. Usually no need to edit. |
| No | Rarely needed | Never | Part of template. Usually no need to edit. |
| No | Yes | Never | Intended for your custom styles. |
You may see this warning in layout.tsx:
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.
When you move the Payload folder, you'll need to update the import path in layout.tsx:
What you can safely edit:
What you should NOT edit:
RootLayout usage (required for Payload)serverFunction pattern (required for Payload to work)RootLayoutThe importMap.js file is automatically regenerated in these scenarios:
pnpm payload generate:importmapThe import map is never regenerated during:
If you see an error about the import map not being found:
admin.importMap.importMapFile points to the correct locationpnpm payload generate:importmap manuallyIf you see an import error in layout.tsx:
layout.tsx to importMap.js./admin/importMap.js if importMap is in a sibling admin folder./importMap.js if you moved importMap to the same folder as layoutIf the admin panel returns 404:
routes.admin matches your actual folder structure(payload) folder, not just adminIf custom components aren't loading:
admin.importMap.baseDir is correctpnpm payload generate:importmapbaseDir