Tongfei Gao
Content Management,  News

Getting Started with the Payload 4 Template

Author

Demo Author

Date Published

The Payload admin panel with live preview of a page, side by side with the rendered website

From one click on Railway to a running site with an admin panel, demo content and AI access.

Demo content: this post was created by the seed script to show off the template. To edit it, open the admin panel.

This template is a complete website built on Payload 4, Next.js and PostgreSQL: pages built from blocks, a blog with nested categories and tags, comments with moderation, search, SEO fields, forms and an MCP endpoint for AI agents. Here is how to get it running and what to do first.

1. Deploy on Railway

The quickest start is the Deploy on Railway button in the repository README. The template provisions:

• The app: Payload and the Next.js website in a single service, with a health check

• PostgreSQL: the database, connected through DATABASE_URL

• A Railway Bucket: private storage for uploaded images, already connected through the S3_* variables, so uploads survive redeploys

• Optional: SMTP: set SMTP_HOST and friends to send real emails such as password resets; without it, emails are written to the server log

Database migrations run automatically when the app starts, so there is nothing to run by hand.

2. Create your admin account

Open /admin on your new site and create the first user. The first account always becomes an admin. Everyone you invite afterwards starts as an editor: editors manage content, while admins also manage users and site setup.

3. Seed the demo content

The dashboard shows a Seed your database button. It fills the site with the pages, posts, categories, tags, images and comments you are looking at right now. Seeding replaces existing content, so use it on a fresh site, and only admins can run it.

Heads up: seeding deletes all pages, posts, media, categories, tags, comments and forms before recreating the demo content. Do not run it on a site with real content.

The Payload admin editing a page, its navigation menu and an image crop, next to the website it powers

Graphic by Payload.

4. Moderate comments

Visitors can comment on every post. New comments arrive as pending and only appear on the site once someone approves them. Approve them from the Comments collection or the Pending comments widget on the dashboard, or let an AI agent do it through the MCP moderateComment tool.

5. Connect an AI agent over MCP

The site speaks the Model Context Protocol, so AI agents and other MCP clients can read and write content for you. In the admin, open your user, enable an API key, and point your MCP client at /api/mcp with this header:

1Authorization: users API-Key <your-api-key>

The agent acts as that user and gets exactly the same permissions, so consider creating a dedicated editor account for it. Deleting posts, pages and media is disabled over MCP: that stays a human decision.

6. Develop locally

You need Node.js 24 and Docker. Clone the repository, copy .env.example to .env, then install dependencies and start PostgreSQL and the dev server:

1corepack pnpm install
2docker compose up -d postgres
3corepack pnpm dev

The site runs on http://localhost:3000. The project also ships Playwright end-to-end tests that walk through onboarding, seeding, the public site, comment moderation and MCP:

1corepack pnpm test:e2e

Looking for Payload 3?

Payload 4 is still in beta. If you would rather build on the stable Payload 3 line, the sibling template has the same idea and the same Railway setup: payload-3-boilerplate. Issues, ideas and pull requests for this template are welcome on GitHub.

  • #Payload
  • #Railway
  • #Tutorial
The Payload admin editing a page, its navigation menu and an image crop, next to the website it powers
Content Management

A practical tour of Payload 4: the redesigned admin, dashboard widgets, nested categories, tags, folders, MCP for AI agents, scheduled publishing and safer defaults.

Comments

No comments yet. Be the first to share your thoughts!

Leave a comment