payload-template-project

Next.js 16 and Payload starter with Clerk auth, Postgres, S3 media storage and Resend email

payload-template-project preview

Overview

Summary generated from the README

A general-purpose starter for customer websites, landing pages and SaaS applications built on Next.js 16 and Payload 3. It wires Clerk authentication to the Payload Users collection, uses PostgreSQL with migration-based schema changes, and stores media in S3-compatible storage. Requires Node 22.14 or newer, pnpm and a PostgreSQL connection string.

Features

  • Clerk authentication backing the Payload Users collection
  • PostgreSQL adapter with push disabled and committed migrations
  • Media collection with image sizes and focal point on S3-compatible storage
  • Resend transactional email integration
  • SEO, redirects and live preview plugins configured
  • Tailwind CSS 4 with shadcn/ui, Lucide icons and Motion

Good for

  • Bootstrapping customer websites on a consistent Next.js and Payload stack
  • Starting SaaS applications that rely on Clerk for user authentication
  • Launching landing pages with S3 media storage and email delivery

From the author

Get started quickly with Next.js, Clerk Auth, Payload CMS and Postgres.

Get started

This repository is a GitHub template: create your own copy of it in one click.

Create a repository from this template

README

Payload Template Project

Internal starter template for building customer websites, landing pages, and SaaS applications on a consistent stack. Bootstrap new projects from this repo instead of starting from scratch — auth, CMS, storage, and UI conventions are already wired up.

Stack

  • Framework: Next.js 16 (App Router)
  • CMS: Payload CMS 3
  • Database: PostgreSQL (via @payloadcms/db-postgres)
  • Auth: Clerk
  • Storage: S3-compatible object storage (media uploads)
  • Email: Resend
  • UI: Tailwind CSS 4, shadcn/ui, Lucide icons, Motion

Requirements

  • Node.js ^22.14.0 or >=24.10.0
  • pnpm ^9, ^10, ^11, or ^12
  • A PostgreSQL connection string (local, Docker, or hosted)

Setup

  1. Clone the repo and install dependencies:

    pnpm install
    
  2. Copy the environment file and fill in the values:

    cp .env.example .env
    
    VariablePurpose
    DATABASE_URLPostgreSQL connection string (postgres://user:pass@host:5432/db)
    PAYLOAD_SECRETPayload's signing secret
    PREVIEW_SECRETSecret used for live preview links
    CRON_SECRETSecret for authenticating scheduled/cron jobs
    NEXT_PUBLIC_SERVER_URLPublic URL the app is served from
    CLERK_SECRET_KEY / NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYClerk API keys
    CLERK_WEBHOOK_SIGNING_SECRETVerifies incoming Clerk webhooks
    NEXT_PUBLIC_CLERK_SIGN_IN_URL, ..._SIGN_IN_FALLBACK_REDIRECT_URL, ..._SIGN_UP_FALLBACK_REDIRECT_URLClerk auth flow routing
    S3_BUCKET, S3_ACCESS_KEY_ID, S3_ACCESS_KEY_SECRET, S3_REGION, S3_ENDPOINTMedia storage (S3-compatible)
    RESEND_API_KEY, RESEND_FROM_EMAIL, RESEND_FROM_NAMETransactional email
  3. Start the dev server:

    pnpm dev
    
  4. Open http://localhost:3000. Follow the on-screen instructions to log in via Clerk and complete first-run setup.

Local PostgreSQL (optional)

docker-compose.yml deploys the application itself and expects an external PostgreSQL instance. For local development you can run PostgreSQL with Docker:

  1. Start a PostgreSQL container:

    docker run --name payload-postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -d postgres:17
    
  2. Set DATABASE_URL in .env, e.g. postgres://postgres:[email protected]:5432/payload.

  3. Apply the schema: pnpm payload migrate.

Database Migrations

The Postgres adapter runs with push: false, so schema changes are applied through migrations rather than automatic dev-time pushes. After changing any collection, global, or field config:

  1. Generate a migration and review it:

    pnpm payload migrate:create
    
  2. Commit the new files under src/migrations/.

  3. Apply pending migrations to the database:

    pnpm payload migrate
    

CI applies migrations before building the image (.github/workflows/push-to-ghcr.yml), and the build prerenders routes against the database, so migrations must be committed before the workflow runs.

Available Scripts

ScriptPurpose
pnpm devStart the Next.js dev server
pnpm buildProduction build
pnpm startServe the production build
pnpm lintRun ESLint
pnpm payloadRun the Payload CLI
pnpm generate:typesRegenerate Payload's TypeScript types from the config
pnpm generate:importmapRegenerate Payload's admin import map
pnpm payload migrate:createGenerate a migration after config changes
pnpm payload migrateApply pending migrations
pnpm payload migrate:statusShow applied and pending migrations

Run pnpm generate:types after changing any collection, global, or field config so generated types stay in sync, and pnpm payload migrate:create so the database schema stays in sync with the config.

Project Structure

  • src/ — application code (Next.js routes, Payload config, collections, components)
  • context/ — living documentation (architecture, UI tokens/rules, code standards, build plan, progress tracker) used to keep new projects built from this template consistent
  • docker-compose.yml — production compose for the app (expects an external PostgreSQL instance)

Collections

  • Users — auth-enabled collection with admin panel access, backed by Clerk.
  • Media — uploads collection with pre-configured image sizes and focal point support, backed by S3-compatible storage.

See the Payload Collections docs to extend either.

Using This as a Starter

When bootstrapping a new internal project from this template:

  1. Update package.json name/description and this README's title.
  2. Review context/ and update it to describe the new project's purpose, scope, and architecture — it should not still describe this template once customized.
  3. Keep the Clerk, Payload, S3, and Resend wiring unless the new project has a reason to diverge — the point of the template is a consistent baseline across projects.

Support

Internal questions: ask in the team channel. For upstream framework issues, see the Payload Discord or Payload GitHub discussions.

Claim this template

More Starters & boilerplates templates

payload-cms-boilerplate screenshot

payload-cms-boilerplate

Blank Payload 3 and Next.js 16 starter with Postgres, Tailwind, shadcn/ui primitives and a built-in SEO module

19
v3
Next.js
Updated 2 months ago
acme-website screenshot

acme-website

Payload 3 starter with Better Auth, Postgres, S3 storage, a blog and composable layout and motion components

122
v3
Next.js
Updated 2 weeks ago
payload-v4-admin-starter screenshot

payload-v4-admin-starter

Payload v4 beta website starter with configurable admin dashboard widgets and a custom semantic admin theme

1
v4
Next.js
Updated Yesterday