ExtantApe

payload plugin maintenance

by ExtantApe
Other
v3
^3.80.0
MIT

Overview

Summary generated from the README

Adds a Maintenance global to the Payload admin with a close-the-site checkbox, heading, message and expected-back line. A gate function for the Next.js proxy serves a small 503 page with Retry-After while the site is closed. The admin, API and signed-in staff stay open. Requires Payload 3.80 or newer and a configured site address to read the switch.

Features

  • Maintenance global with close checkbox, heading, message and expected-back line
  • Next.js proxy gate that answers with HTTP 503 and Retry-After
  • Admin and API paths stay open so staff can reopen and webhooks keep running
  • Signed-in session cookie bypass, which can be disabled
  • SITE_MAINTENANCE environment variable overrides the admin switch
  • Script-free page with light and dark colours and a configurable theme

Use cases

  • Close a site temporarily during a deploy or migration without blocking the admin
  • Show search engines a temporary 503 while content is being updated
  • Let staff preview a closed site before reopening it to visitors

From the author

Maintenance mode for Payload: close a site with a back-soon page and HTTP 503 from an admin switch, while the admin, API and signed-in staff keep working.

Installation

npm i @extantape/payload-plugin-maintenance

0

Stars

0

Forks

0

Open Issues

1 weeks ago

Last Updated

388

Weekly Downloads

v0.3.0

npm Version

31.7 KB

Unpacked Size

0

Dependencies

GitHub stars

00 since Nov 8

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
npm weekly downloads

396+396 since Nov 11

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 2026396
Dec 5, 2026430
Dec 4, 2026600
Dec 3, 2026623
Dec 2, 2026639
Dec 1, 2026651
Nov 30, 2026467
Nov 29, 2026550
Nov 28, 2026529
Nov 27, 2026362
Nov 26, 2026337
Nov 25, 2026312
Nov 24, 2026280
Nov 23, 2026246
Nov 22, 2026355
Nov 21, 2026325
Nov 20, 2026314
Nov 19, 2026280
Nov 18, 2026262
Nov 17, 2026235
Nov 16, 2026219
Nov 15, 20260
Nov 14, 2026304
Nov 13, 2026270
Nov 12, 2026167
Nov 11, 20260

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

Health Score

78/100Excellent

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/1451746696-root.svg)](https://payloaddirectory.dev/plugins/1451746696-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1451746696-root"><img src="https://payloaddirectory.dev/badge/1451746696-root.svg" alt="Payload Directory"></a>
Updated Nov 29, 2026Created Nov 9, 2026Published Nov 28, 2026

README

payload-plugin-maintenance

Maintenance mode for Payload: close a site with a back-soon page and HTTP 503 from an admin switch, while the admin, API and signed-in staff keep working.

Status: early (0.3.0). From 0.2.0 it is published as @extantape/payload-plugin-maintenance; the earlier package name is deprecated in its favor. Unit tests cover the page, the global's access and the gate (switch, environment override, sign-in bypass, cache, failed reads, the Vercel protection header, the configured site address and redirects). The Vercel address defaults are tested with made-up values only, not on a Vercel deployment. The same approach already runs on a live site as a hand-written switch; this package hasn't been installed in a real site yet.

What it does

  • Adds a Maintenance global to the admin: a "Close the site" checkbox, a heading, a message and an optional "Expected back" line.
  • Gives you a gate for your Next.js proxy (middleware). While the site is closed, every page answers one small page with HTTP 503 and Retry-After, so search engines treat it as temporary. Nothing is cached, so reopening shows at once.
  • The admin and the API always stay open: you can sign in and reopen, and webhooks and crons keep running.
  • Anyone signed in (Payload's session cookie) still sees the site, so staff can check it before reopening. That's a convenience, not access control: the cookie's presence is enough, and your pages enforce their own access as usual. Turn it off with bypassCookie: false.
  • An environment variable (SITE_MAINTENANCE=on or off) overrides the switch, for when the admin itself is down or you want a deploy to start closed.
  • The page has light and dark colours, no scripts and no outside requests. Everything typed in the admin is shown as plain text.

Limits:

  • The switch is read over your site's REST API and reused for 10 seconds per server instance, so a change can take that long to show everywhere.
  • The gate needs to know your site's address (see Site address). Without it the switch can't be read.
  • Don't use maintenance mode to hide content that is unsafe for children. Unpublish that content. The API stays open, signed-in people still see the site, and the site stays open when the switch has never been read.
  • If the switch can't be read, the last answer stands; if it has never been read, the site stays open. Maintenance is a courtesy page, not a security control, so an API outage shouldn't close the site. The gate writes the reason to the server log (console.error), once per reason until a read works again. A missing or invalid address or apiRoute is also logged when the gate is built, which is when your proxy module loads.
  • One switch per deployment. A multi-tenant site closes every tenant together.
  • On Vercel with Deployment Protection, the gate's request to its own API is refused unless "Protection Bypass for Automation" is on; the gate sends VERCEL_AUTOMATION_BYPASS_SECRET when it exists.

On its own, and with others

On its own: Maintenance needs only Payload and a Next.js proxy. It adds one global and a gate, and reads the switch over your site's own API.

Needs: Payload ^3.80.0 as a peer dependency. No other EXTANT APE plugin is required.

Works with: any plugin, since it doesn't touch their collections or routes. The admin and API stay open while the site is closed, so other plugins' webhooks and scheduled jobs keep running. Nothing in it is built for one plugin in particular.

Color Theory: none yet. The maintenance page takes its colors from the theme option, with fixed defaults. Nothing reads Color Theory's tokens for it.

Family: Maintenance has no family on purpose: it sits beside every plugin. The families are a working draft, and Fulfillment is due to be split.

Install

npm install @extantape/payload-plugin-maintenance
// payload.config.ts
import { maintenance } from '@extantape/payload-plugin-maintenance'

export default buildConfig({
  // ...
  plugins: [maintenance({ access: ({ req }) => req.user?.role === 'admin' })],
})
// src/proxy.ts (Next.js 16; middleware.ts on older versions)
import { maintenanceGate } from '@extantape/payload-plugin-maintenance/gate'

// Self-hosted: also set SITE_MAINTENANCE_ORIGIN, or pass `origin` here. See "Site address".
const gate = maintenanceGate({ brand: 'My Site' })

export async function proxy(request: NextRequest) {
  const closed = await gate(request)
  if (closed) return closed
  // ...the rest of your proxy
}

export const config = { matcher: ['/((?!admin|api|_next|favicon.ico).*)'] }

Site address

The gate reads the switch from the address you configure. It takes the first of these that is set:

  1. The origin option, for example maintenanceGate({ origin: 'https://www.example.com' }).
  2. The SITE_MAINTENANCE_ORIGIN environment variable.
  3. On Vercel, from Vercel's system environment variables: VERCEL_PROJECT_PRODUCTION_URL in production, VERCEL_URL in previews and other deployments. Production also uses VERCEL_URL when VERCEL_PROJECT_PRODUCTION_URL is absent. The project has to expose them to deployments.

Self-hosted sites must set 1 or 2. On Vercel you need to set one only if the system variables aren't exposed, or if the address Vercel gives redirects to another one (for example example.com to www.example.com). In that case use the address that answers directly.

Write it as scheme and host, with a port if needed: https://www.example.com or http://127.0.0.1:3000. A path, query or sign-in details make it invalid; a base path goes in apiRoute. Write apiRoute with a leading / (for example /shop/api). The gate doesn't check for the slash itself. It checks that the resulting request stays on the configured address. Don't set apiRoute or adminRoute to '' or '/'. Any of these opens every path, so the gate never closes the site, even with SITE_MAINTENANCE=on, and it logs no warning about this.

The address can be internal, as long as your proxy can reach the API there. Use https unless the request stays on a network you trust. If you run several environments, give each its own address, so each reads its own switch.

The gate follows up to 3 redirects that stay on that address. It doesn't follow a redirect to another one, including http to https.

If the address is missing or invalid, the gate can't read the switch. The site stays open, even if "Close the site" is ticked, and the server log says why. An invalid value isn't replaced by the next one in the list. An apiRoute that would send the request anywhere other than that address is treated the same way, and nothing is sent. SITE_MAINTENANCE=on still closes the site, with the default words. After upgrading or changing the address, tick "Close the site" once and check that a signed-out visitor sees the page.

Upgrading from 0.2.0

0.3.0 has a breaking change: the gate reads the switch only from a configured site address. Check each of these before you upgrade:

  • Self-hosted: pass origin or set SITE_MAINTENANCE_ORIGIN. Use the scheme, host and optional port, with no path. A base path goes in apiRoute. Until this is set, the site is open to signed-out visitors, even if "Close the site" is already ticked.
  • Vercel, system environment variables not exposed: expose them to deployments, or set SITE_MAINTENANCE_ORIGIN.
  • Vercel, production domain redirects (for example example.com to www.example.com, or to another domain): set SITE_MAINTENANCE_ORIGIN to the address that answers directly.
  • An API that redirects to another host, port or scheme (including http to https): configure the final address.
  • A custom read that used its argument: it now gets the configured address, or an empty string if there is none.
  • Several environments that share one env file: give each its own address.
  • After upgrading: tick "Close the site" once and check that a signed-out visitor sees the page.

If the site has to stay closed while you upgrade, set SITE_MAINTENANCE=on until that check is done. While it's set, the page shows whether or not the switch can be read, so unset it before the check.

Access

access decides who can close and reopen the site and edit the page. It's a Payload Access function and goes to Payload as the global's update access as it is.

With no access, only users of your admin collection (admin.user in your Payload config, usually users) can change it. Anyone signed in through another auth collection, such as site members, is refused, and so is everyone if the config names no admin collection. Reading the global stays open to anyone: it holds nothing private.

Changed in 0.2.0 (2026-11-11): the default used to let any signed-in account change the switch, members of other auth collections included. Sites relying on the old default must pass the option, for example access: ({ req }) => Boolean(req.user).

Gate options: origin, slug, apiRoute, adminRoute, openPaths, envVar, bypassCookie, cacheSeconds, retryAfterSeconds, brand, lang, theme (light and dark colours), and read to supply your own reader. Your reader gets the configured address, or an empty string if there is none.

Commands

npm test          # Vitest
npm run typecheck
npm run build     # dist/

Releasing: see RELEASING.md.

License

MIT

Similar plugins