Adds a neutral birth month and year check for sign-up that classifies a person as too young, a minor or an adult using a table of ages by country and region. It adds a minorUntil field and a hidden cap to the users collection, with a signed cookie to keep too-young visitors blocked and an adult question once the date passes. Requires Payload 3.80 or newer and React 19 or newer; transactions need MongoDB as a replica set.
Age gate for Payload: a neutral birth month and year check at sign-up that stores only how long an account is a minor, from a table of ages by country, with a stay-blocked cookie and an "are you an adult now?" step.
Installation
npm i @extantape/payload-plugin-age-gate0
Stars
0
Forks
1
Open Issues
2 days ago
Last Updated
140
Weekly Downloads
v0.2.0
npm Version
47.2 KB
Unpacked Size
0
Dependencies
00 since Nov 8
| Date | Stars |
|---|---|
| Dec 5, 2026 | 0 |
| Dec 4, 2026 | 0 |
| Dec 3, 2026 | 0 |
| Dec 2, 2026 | 0 |
| Dec 1, 2026 | 0 |
| Nov 30, 2026 | 0 |
| Nov 29, 2026 | 0 |
| Nov 28, 2026 | 0 |
| Nov 27, 2026 | 0 |
| Nov 26, 2026 | 0 |
| Nov 25, 2026 | 0 |
| Nov 24, 2026 | 0 |
| Nov 23, 2026 | 0 |
| Nov 22, 2026 | 0 |
| Nov 21, 2026 | 0 |
| Nov 20, 2026 | 0 |
| Nov 19, 2026 | 0 |
| Nov 18, 2026 | 0 |
| Nov 17, 2026 | 0 |
| Nov 16, 2026 | 0 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 0 |
| Nov 13, 2026 | 0 |
| Nov 12, 2026 | 0 |
| Nov 11, 2026 | 0 |
| Nov 10, 2026 | 0 |
| Nov 9, 2026 | 0 |
| Nov 8, 2026 | 0 |
186+186 since Nov 13
| Date | Weekly downloads |
|---|---|
| Dec 5, 2026 | 186 |
| Dec 4, 2026 | 358 |
| Dec 3, 2026 | 391 |
| Dec 2, 2026 | 416 |
| Dec 1, 2026 | 441 |
| Nov 30, 2026 | 478 |
| Nov 29, 2026 | 566 |
| Nov 28, 2026 | 549 |
| Nov 27, 2026 | 407 |
| Nov 26, 2026 | 573 |
| Nov 25, 2026 | 549 |
| Nov 24, 2026 | 513 |
| Nov 23, 2026 | 478 |
| Nov 22, 2026 | 556 |
| Nov 21, 2026 | 518 |
| Nov 20, 2026 | 481 |
| Nov 19, 2026 | 257 |
| Nov 18, 2026 | 238 |
| Nov 17, 2026 | 214 |
| Nov 16, 2026 | 198 |
| Nov 15, 2026 | 0 |
| Nov 14, 2026 | 186 |
| Nov 13, 2026 | 0 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1453189722-root)<a href="https://payloaddirectory.dev/plugins/1453189722-root"><img src="https://payloaddirectory.dev/badge/1453189722-root.svg" alt="Payload Directory"></a>README
Age gate for Payload: a neutral birth month and year check at sign-up that stores only how long an account is a minor, from a table of ages by country.
Status: early, 0.x. 45 tests pass: the age arithmetic, the cookie, the fields, the adult question and the transactions, against a real Payload 3.92 with an in-memory MongoDB. The picker hasn't been tried in a browser yet, and it isn't in use on any site yet. The table of ages hasn't been checked by a lawyer. Have yours check it for the places you serve before you rely on it.
minorUntil (written YYYY-MM, always a January): the January after they're of age where they live, plus a hidden cap. Nobody can work a birth month back from it. The cost is that an account counts as a minor for up to about 12 months longer than it strictly has to, never shorter.minorUntil has passed, the person answers. Yes clears it. No moves it a year on, but never past the highest age of majority anywhere (21), so nobody stays a minor indefinitely.minorUntil or minorCap, by staff, a host or the plugin, is stored as the next January. Anything that isn't a month or a year is refused.coarsenStoredAges(payload) once after upgrading: it covers minorUntil and minorCap, runs in one transaction and is safe to run again. It lists any account whose value can't be read, for staff to fix by hand. An old block cookie with a valid signature still blocks (read as a January), and is replaced with a year cookie when it's next seen.canSetMinor (staff) can change minorUntil. Every change goes to onEvent, for your audit log.canSetMinor can read minorUntil. Only an exact true from canSetMinor counts: see Access.It's self-declared, not verified. A child can choose a false year or clear their cookies. This checks what people tell you, protectively; it doesn't prove anyone's age.
What a minor may do on your site is up to your access rules: isMinor(user.minorUntil).
On its own: it adds minorUntil and a hidden cap to your users collection, plus the signed-in adult question. Your own form calls ageGateCheck and applyAgeGate, and your access rules call isMinor. It doesn't depend on any other plugin.
Needs: Payload ^3.80.0 and React >=19 as peer dependencies. No other EXTANT APE plugin is required.
Works with:
ageGateCheck in Sign-up's checks. It refuses anyone too young, flags a minor for staff, and hands minorUntil to the new account as userData. The birth month and year go in as answers, which Sign-up never stores. The stay-blocked cookie goes back as setCookies, which Sign-up sets on its response (Sign-up's next release; with 0.1.0 it's lost). Neither plugin imports the other: the check returns plain values.isMinor can read this plugin's field: (user) => isMinor(user.minorUntil).onEvent through Audit Trail's fromPluginEvent, so every change to a minor status lands in the tamper-evident trail.Color Theory: no direct link. Its client form brings no colors of its own and takes your site's CSS, so a site styled with Color Theory's --palette-* tokens styles it too.
Family: It's part of the Identity family (a working draft): plugins designed to sit together for accounts and access. The others are Sign-up, MFA, Hats, Guardians, User Controls, Roles and Masq.
import { ageGate, ageGateCheck } from '@extantape/payload-plugin-age-gate'
plugins: [
ageGate({
secret: process.env.PAYLOAD_SECRET!, // signs the stay-blocked cookie (32+ characters)
canSetMinor: ({ req }) => isStaff(req.user),
onEvent: (e) => audit(e), // minor-set, minor-cleared, asked-again
// ages: { ...AGES, XX: { consent: 13, majority: 18 } }, // after your lawyer's review
}),
]
// With @extantape/payload-plugin-signup, or your own form:
const check = ageGateCheck({ secret: process.env.PAYLOAD_SECRET! })
// check({ answers: { country, region, birthYear, birthMonth }, req }) → { refuse, setCookies? } | { flag: 'minor', userData } | undefined
// It reads the stay-blocked cookie from req.headers. Too young: set each of setCookies as a Set-Cookie header on your response.
// After creating the user, record a minor with applyAgeGate(payload, { userId, userData, req }).
// The update and your `onEvent` audit entry always commit together: the plugin opens a transaction unless your `req`
// already has one. If `onEvent` throws, the plugin writes the minor flag again on its own and the error reaches you,
// so the account is never left looking like an adult. If your `req` already has a transaction, the create and this
// call share it: when it throws, roll the whole transaction back, so the account isn't left without its flag.
// The fields can't be written through access-checked creates, so passing userData with overrideAccess: false would drop it.
The picker, for your form: import { BirthMonthYear } from '@extantape/payload-plugin-age-gate/client'. It posts birthMonth and birthYear, and every word can be replaced for translation.
The adult question: POST /api/users/age-gate/adult with { "adult": true | false }, signed in.
canSetMinor decides who is staff, and only an answer of exactly true counts, for a signed-in user.
Anything else is a no: false, 1, 'yes', an object, or an error thrown or rejected. An error
doesn't escape as a 500: the field is simply left out or left unchanged, as for anyone else who
isn't staff. Payload's field access has no queries, so canSetMinor's answer is never passed to it.
| Field | Staff | The person | Anyone else, or signed out |
|---|---|---|---|
minorUntil | Reads, sets, clears | Reads only | Never sees it |
minorCap | Reads, sets, clears | Never sees it | Never sees it |
The person clears their own status only through the adult question above, and applyAgeGate
records a sign-up's result with full access.
A member can't find minors by filtering or sorting on minorUntil; a test covers it.
Keep createdAt with staff. minorUntil is a January, but together with when the account was made it narrows the
birth month: an account made in June 2030 that is a minor until January 2031 was born in June or later. Show the two
together only to staff.
Transactions need MongoDB as a replica set (Atlas is one). On a standalone server Payload runs without them, so the update and the audit entry can't roll back together.
npm test # Vitest, in-memory MongoDB
npm run typecheck
npm run build
MIT. See LICENSE.
payload plugin sharing
Share records with users and organizations through groups with Owner, Manager and Viewer levels
76425/wk0v3
payload plugin guardians
Link minors to guardians, turn guardian edits into suggestions the minor decides, and route requests for approval
76366/wk0v3
plugin consent
Cookie consent managed in the Payload admin: categories, trackers, banner, script gating and consent records.
7044/wk10v3
multi tenant
Manage multiple tenants and tenant-scoped content from a single Payload admin panel
100165.4k/wk46.1kv3 v4
consent
Cookie banner and consent control with Google Consent Mode v2 and personal data consent in forms
77621/wk0v4
payload plugin positions
Scoped, dated position grants for users on a site, organization or project, with host-defined types and an audit trail
76382/wk0v3