jamesvclements

next payload starter

by jamesvclements
Other
v?

Overview

Summary generated from the README

A starter repository combining a Next.js site and a Payload CMS backend in one monorepo, styled with Tailwind CSS. It includes a payload-mux plugin that uploads videos to Mux, syncs metadata back and handles deletion through webhooks. A payload-vercel plugin helps revalidate the front end and view deployments. The author describes it as early stage and aimed at Payload 2.x style separate deployments.

Features

  • Monorepo with separate Next.js site and Payload CMS folders run from the root
  • Mux plugin uploads videos from a videos collection and syncs metadata like aspect ratio
  • Mux webhook keeps deleted videos in sync with CMS documents
  • Vercel plugin for front-end revalidation and viewing latest deployments
  • Tailwind CSS setup with desktop-first breakpoints
  • Type generation script for sharing payload types with the site

Use cases

  • Start a custom marketing site that clients can edit themselves with Payload
  • Host and stream videos through Mux while managing them in Payload
  • Trigger front-end revalidation on Vercel after CMS content changes

From the author

Opinionated starter kit for custom websites built on Next.js and Payload CMS

Installation

npm i next-payload

35

Stars

3

Forks

2

Open Issues

2 years ago

Last Updated

0

Weekly Downloads

v

npm Version

Dependencies

GitHub stars

350 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 202635
Dec 4, 202635
Dec 3, 202635
Dec 2, 202635
Dec 1, 202635
Nov 30, 202635
Nov 29, 202635
Nov 28, 202635
Nov 27, 202635
Nov 26, 202635
Nov 25, 202635
Nov 24, 202635
Nov 23, 202635
Nov 22, 202635
Nov 21, 202635
Nov 20, 202635
Nov 19, 202635
Nov 18, 202635
Nov 17, 202635
Nov 16, 202635
Nov 15, 202635
Nov 14, 202635
Nov 13, 202635
Nov 12, 202635
Nov 11, 202635
Nov 10, 202635
Nov 9, 202635
Nov 8, 202635
Nov 7, 202635
Nov 6, 202635
Nov 5, 202635
Nov 4, 202635
Nov 3, 202635
Nov 2, 202635
Nov 1, 202635
Oct 31, 202635
Oct 30, 202635
Oct 29, 202635
Oct 28, 202635
Oct 27, 202635
Oct 26, 202635
Oct 25, 202635
Oct 24, 202635
Oct 23, 202635
Oct 22, 202635
Oct 21, 202635
Oct 20, 202635
Oct 19, 202635
Oct 18, 202635
Oct 17, 202635
Oct 16, 202635
Oct 15, 202635
Oct 14, 202635
Oct 13, 202635
Oct 12, 202635
Oct 11, 202635
Oct 10, 202635
Oct 9, 202635
Oct 8, 202635
Oct 7, 202635
Oct 6, 202635
Oct 5, 202635
Oct 4, 202635
Oct 3, 202635
Oct 2, 202635
Oct 1, 202635
Sep 30, 202635
Sep 29, 202635
Sep 28, 202635
Sep 27, 202635
Sep 26, 202635
Sep 25, 202635
Sep 24, 202635
Sep 23, 202635
Sep 22, 202635
Sep 21, 202635
Sep 20, 202635
Sep 19, 202635
Sep 18, 202635
Sep 17, 202635
Sep 16, 202635
Sep 15, 202635
Sep 14, 202635
Sep 13, 202635
Sep 12, 202635
Sep 11, 202635
Sep 10, 202635
Sep 9, 202635
Sep 8, 202635
Sep 7, 202635
Sep 6, 202635
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

15/100Poor

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/700588599-root.svg)](https://payloaddirectory.dev/plugins/700588599-root)
HTML
<a href="https://payloaddirectory.dev/plugins/700588599-root"><img src="https://payloaddirectory.dev/badge/700588599-root.svg" alt="Payload Directory"></a>
Updated Sep 23, 2024Created Oct 4, 2023

README

next-payload-starter

Edit 6/5/24 — Payload 3.0 is almost out of beta and will be a huge improvement over the "deploying" part of this repo, as it all works inside the Next.js app deployed on Vercel. I will try to update this when I can, in the meantime check out Payload 3.0. However the payload-mux and payload-vercel plugins in the CMS directory of this repo are relevant for either version of Payload.

This is an opinionated starter repository for building marketing sites on Next.js and Payload CMS. This is the same stack I use for client sites at Old Friends when Webflow or Framer won't do the trick. While the setup is based on my own dev preferences, I'm hopeful this is useful for anyone looking to build highly-custom sites that clients can update themselves.

preview

WIP Disclaimer

Please note this is still in early stages. I can't guarantee the correctness of anything in this repo. I try to revisit it with each client project and add improvements, but it's difficult to always keep it in sync with the latest features coming out of each package and my own learnings. My rule of thumb is that if 80% of my projects will use a feature or component, it belongs in the starter.

Structure and Opinions

  • This is a monorepo for both the site and CMS. The site is deployed on Vercel, the CMS is deployed on a cloud provider of your choice. I currently use Google Cloud for the server, Atlas for the database, and Cloudflare for object storage. Payload may be moving to Next, after which the site and cms will be able to be hosted in the same Vercel project, which would be ideal.
  • For styling, I use Tailwind CSS as much as possible and normal CSS files when needed. Most projects benefit from using both. The Tailwind breakpoints are customized to be desktop-first (instead of mobile-first). I've always found this to be more intuitive, and it's aligned with the other tools I use like Webflow and Framer.

Setup

You should be able to run the entire project from the root folder, rather than separate processes for the site and cms.

  1. Clone the repo
  2. Install the dependencies with yarn
  3. Add the necessary env variables following cms/.env.example and site/.env.example
    • For the CMS, you'll need to create a database and object storage. I use Atlas MongoDB and Cloudflare S3. Set these up through their respective web dashboards, then copy over the env variables.
  4. Run yarn dev to start both the CMS and site and begin developing. You may need to visit the CMS first to populate a few things.
  5. As you build out the CMS, run yarn types to keep the generated payload-types file up to date so you can use it in the site's components.

Deploying

Documentation incoming...Vercel for the site, Google Cloud Build Trigger and Run for the CMS (for now).

Payload Plugins

This repo also includes two custom plugins I've written for Payload CMS, described below. I'm hoping to publish these on NPM soon. For now, if you'd like to use one, simply copy the plugin's folder (e.g. payload-mux) and paste it into your own project.

payload-mux

Mux is a fantastic platform for hosting and streaming video. This plugin customizes your videos collection to automatically upload videos into your Mux project, load the metadata (like aspect ratio and size) back into the CMS, and keeps them in sync:

Setup

  1. Add the payload-mux folder into your CMS

  2. Install the plugin dependencies

    yarn add @mux/mux-node @mux/mux-uploader-react @mux/mux-player-react
    
  3. Add the necessary env variables

    MUX_TOKEN_ID=
    MUX_TOKEN_SECRET=
    MUX_WEBHOOK_SIGNING_SECRET=
    
  4. In the Mux dashboard, add a webhook to https://your-cms-url.com/api/mux/webhook. This way when videos are deleted within the Mux dashboard, the corresponding document in your videos collection is deleted as well. If you need to test this locally, use ngrok or LocalCan. The plugin will technically work without doing this but it's a good practice to keep them in sync, otherwise you'll have stale video documents.

  5. Initialize the plugin inside your payload.config.ts

    plugins: [
      payloadMux({
        enabled: true,
        collection: 'videos',
      }),
    
  6. That's it! You should now be able to upload videos to Mux directly through Payload 🍿

Demo

https://github.com/jamesvclements/next-payload-starter/assets/20052710/5c9a6cde-fea1-4e33-b88a-84009b12120b

payload-vercel

Documentation incoming...this plugin helps you revalidate your front-end when you change things in the CMS, as well as force revalidations when needed, and view latest deployments.

(Notes to self)

Todos

  • Continue cleaning up lingering bits that aren't specific to starter
  • Remove the grep command from /site/package.json that starts dev on the PORT env var. This is helpful but not cross-platform.
  • Use Upchunk for file uploading and remove dependency on Payload's upload UI

Next Steps

  • Take advantage of the shared folder for settings used on both the front-end and server, like some env variables and the generated payload-types.ts

Similar plugins