OkCripto

payload cms

by OkCripto
Other
v?

Overview

Summary generated from the README

A demo vacation-rental marketplace made of two independent Next.js apps sharing one Neon Postgres database. The Payload admin app manages stays, locations, property types, stay types and amenities, and is the only writer. The storefront reads the same data directly through a SELECT-only Postgres role. It is a full example project rather than an installable plugin.

Features

  • Payload admin collections for stays, locations, property types, stay types and amenities
  • Server-rendered storefront with text search, price slider and URL-synced filters
  • SELECT-only Postgres role with a script that verifies reads work and writes are rejected
  • Idempotent seed script and Payload migrations for the Postgres schema
  • Designed for independent deployment to Cloudflare Workers via OpenNext

Use cases

  • Study how to split a Payload admin from a read-only storefront sharing one database
  • Bootstrap a booking or vacation-rental marketplace on Payload and Neon Postgres

0

Stars

0

Forks

0

Open Issues

2 months ago

Last Updated

0

Weekly Downloads

v

npm Version

Dependencies

GitHub stars

00 since Sep 20

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20260
Dec 5, 20260
Dec 4, 20260
Dec 3, 20260
Dec 2, 20260
Dec 1, 20260
Nov 30, 20260
Nov 29, 20260
Nov 28, 20260
Nov 27, 20260
Nov 26, 20260
Nov 25, 20260
Nov 24, 20260
Nov 23, 20260
Nov 22, 20260
Nov 21, 20260
Nov 20, 20260
Nov 19, 20260
Nov 18, 20260
Nov 17, 20260
Nov 16, 20260
Nov 15, 20260
Nov 14, 20260
Nov 13, 20260
Nov 12, 20260
Nov 11, 20260
Nov 10, 20260
Nov 9, 20260
Nov 8, 20260
Nov 7, 20260
Nov 6, 20260
Nov 5, 20260
Nov 4, 20260
Nov 3, 20260
Nov 2, 20260
Nov 1, 20260
Oct 31, 20260
Oct 30, 20260
Oct 29, 20260
Oct 28, 20260
Oct 27, 20260
Oct 26, 20260
Oct 25, 20260
Oct 24, 20260
Oct 23, 20260
Oct 22, 20260
Oct 21, 20260
Oct 20, 20260
Oct 19, 20260
Oct 18, 20260
Oct 17, 20260
Oct 16, 20260
Oct 15, 20260
Oct 14, 20260
Oct 13, 20260
Oct 12, 20260
Oct 11, 20260
Oct 10, 20260
Oct 9, 20260
Oct 8, 20260
Oct 7, 20260
Oct 6, 20260
Oct 5, 20260
Oct 4, 20260
Oct 3, 20260
Oct 2, 20260
Oct 1, 20260
Sep 30, 20260
Sep 29, 20260
Sep 28, 20260
Sep 27, 20260
Sep 26, 20260
Sep 25, 20260
Sep 24, 20260
Sep 23, 20260
Sep 22, 20260
Sep 21, 20260
Sep 20, 20260
npm weekly downloads

Trends appear after 7 days of data. Daily snapshots have not started yet.

Each point is npm's rolling 7-day download count.

Health Score

25/100Fair

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1388798370-root.svg)](https://payloaddirectory.dev/plugins/1388798370-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1388798370-root"><img src="https://payloaddirectory.dev/badge/1388798370-root.svg" alt="Payload Directory"></a>
Updated Sep 27, 2026Created Sep 26, 2026

README

payload-cms-demo

Payload CMS

Short-stays booking marketplace — a Payload CMS dashboard and a read-only Next.js storefront, backed by Neon Postgres

Next.js Payload CMS Neon Drizzle Cloudflare TypeScript

Features • Architecture • Project structure • Getting started • Deployment

A demo short-stays (vacation-rental) marketplace split into two independent Next.js apps that share one Neon Postgres database — and nothing else.

cms-dash is the Payload admin dashboard where every listing and taxonomy value is managed. staybooking_front is the public storefront that reads the same data straight from the database through a SELECT-only role. There is no API between the two apps: the storefront queries Neon directly from React Server Components, so both apps stay simple and deploy independently to Cloudflare.

Features

  • Marketplace storefront — server-rendered stay cards (image, property & stay type badges, per-night price, location, amenity icons) with text search, a price-range slider, and multi-select filters synced to the URL, so any filtered view is shareable and bookmarkable.
  • Payload admin dashboard — manage stays, locations, property types, stay types, and amenities; the Postgres schema is owned by Payload migrations, with an idempotent seed script for demo data.
  • Data-driven taxonomy — every filter option comes straight from a lookup table. Add a city or amenity in the admin and it shows up as a new filter option and card badge with zero code changes.
  • Enforced read-only frontend — the storefront connects with a dedicated SELECT-only Postgres role. A SQL script provisions it and a verification script proves it can read but not write.
  • Cloudflare-ready by design — queries run over Neon's HTTP (fetch-based) driver and the apps never call each other, so each one deploys independently to Workers/Pages.

Architecture

flowchart LR
    A([Admin]) --> C[cms-dash<br>Payload CMS]
    C -- "read + write" --> D[(Neon Postgres)]
    D -- "SELECT only" --> F[staybooking_front<br>Next.js marketplace]
    F --> V([Site visitors])
  • cms-dash — Next.js + Payload with the Postgres adapter (Drizzle under the hood). It is the only writer. Collections: Stays, Locations, Property Types, Stay Types, Amenities, Users. Everything lives under /admin; the root URL redirects there.
  • staybooking_front — Next.js App Router storefront. Server components fetch data through a read-only Drizzle client built on @neondatabase/serverless, and filter state lives entirely in the URL.
  • Neon Postgres — the single source of truth. Lookup tables (locations, property_types, stay_types, amenities), the stays table referencing them by foreign keys, plus Payload-managed child tables for image URLs and amenity relations. The database stores image URLs only — binaries live wherever the images are hosted.

[!IMPORTANT] The read-only contract is the core of this architecture. cms-dash must be the only writer. staybooking_front must never hold credentials with INSERT/UPDATE/DELETE/DDL privileges — not locally, not in production.

Project structure

.
├── cms-dash/                  # Payload CMS admin dashboard (read + write)
│   ├── payload.config.ts      # Payload config (Postgres adapter, migrations)
│   ├── src/collections/       # Users, Locations, PropertyTypes, StayTypes, Amenities, Stays
│   ├── src/migrations/        # Postgres schema, owned by Payload
│   └── src/seed.ts            # Idempotent seed: lookup rows + sample stays
├── staybooking_front/         # Public marketplace (read-only)
│   ├── app/                   # App Router pages (server components)
│   ├── components/            # Marketplace UI (filters, cards) + UI primitives
│   ├── lib/db/                # Read-only Drizzle schema + Neon HTTP client
│   ├── lib/queries.ts         # SELECT-only data-fetching layer
│   └── scripts/               # readonly-role.sql + verify-readonly.ts
└── AGENTS.md                  # Architecture rules & conventions

Getting started

Prerequisites:

  • Node.js 20+ and npm
  • A Neon project (the free tier is fine) with an admin connection string

1. Set up the database and admin dashboard

cd cms-dash
npm install

Create cms-dash/.env:

DATABASE_URI=postgresql://<admin-user>:<password>@<host>-pooler.<region>.aws.neon.tech/neondb?sslmode=require
PAYLOAD_SECRET=<any-long-random-string>
# NEXT_PUBLIC_SERVER_URL=https://your-deployed-admin.example.com  (optional)

Apply the schema, seed demo data, and start the dashboard:

npm run migrate     # creates the tables from Payload migrations
npm run seed        # lookup rows (cities, BHK types, amenities…) + 3 sample stays
npm run dev         # open http://localhost:3000 → /admin, create the first admin user

[!TIP] Payload's Postgres adapter uses the raw pg driver, which occasionally trips over PgBouncer's prepared statements on the pooled endpoint. If a migration fails with a prepared-statement error, temporarily use Neon's direct (non-pooler) connection string, run the migration, then switch back.

2. Create the read-only role

Run staybooking_front/scripts/readonly-role.sql in the Neon SQL editor while logged in as the project owner. Replace the placeholder password and the admin role name in the default-privileges clause, then build the pooled connection string for the new staybooking_readonly role.

3. Run the storefront

cd ../staybooking_front
npm install

Create staybooking_front/.env.local:

DATABASE_READONLY_URL=postgresql://staybooking_readonly:<password>@<host>-pooler.<region>.aws.neon.tech/neondb?sslmode=require

Verify the read-only contract — the script should report that reads work and writes are rejected by Postgres:

npx tsx scripts/verify-readonly.ts
npm run dev         # http://localhost:3000

Environment variables

AppFileVariableDescription
cms-dash.envDATABASE_URINeon admin connection string (pooled)
cms-dash.envPAYLOAD_SECRETSecret used by Payload for auth/crypto
cms-dash.envNEXT_PUBLIC_SERVER_URLOptional public URL of the deployed dashboard
staybooking_front.env.localDATABASE_READONLY_URLConnection string of the SELECT-only Postgres role

Scripts

cms-dash

CommandDescription
npm run devStart the admin dashboard in dev mode
npm run build / startProduction build / serve
npm run migrateApply pending Payload migrations
npm run migrate:createGenerate a migration from collection config changes
npm run migrate:freshDrop and recreate the schema, then re-apply (destructive)
npm run seedIdempotent seed of lookup rows and sample stays
npm run generate:typesRegenerate Payload TypeScript types

staybooking_front

CommandDescription
npm run devStart the storefront in dev mode
npm run build / start / lintStandard Next.js scripts
npx tsx scripts/verify-readonly.tsVerify the SELECT-only database contract

Adding new filter options

New cities, property types, stay types, or amenities are just data: add a row in the matching Payload collection (or INSERT into the lookup table). The storefront's filter sidebar and card badges read these tables on every render, so new values appear automatically — no code change, no redeploy. Stays always reference lookup rows by foreign key, never by copied strings, so renames and edits propagate everywhere.

Deployment

Both apps are designed to deploy independently to Cloudflare Workers/Pages via OpenNext / @opennextjs/cloudflare and Wrangler:

  • The storefront is Workers-ready out of the box: Neon's HTTP driver sends queries over fetch, which the Workers runtime supports. Set the read-only role's connection string as a Worker secret.
  • The admin dashboard uses Payload's pg-based adapter (raw TCP), which requires Hyperdrive or a compatible TCP proxy in a Worker environment.

No Wrangler configs are committed yet; see AGENTS.md for the architecture rules and conventions any deployment should follow.

Similar plugins