navanem

payload contact

by navanem
Forms
v3
^3.90.0
MIT

Overview

Summary generated from the README

Adds a contact-messages collection, a settings global and a submit endpoint to Payload. Includes a drop-in ContactForm client component and an admin inbox view with message stats. Spam is handled with a honeypot field, a per-IP rate limit and blocked keywords. Requires Payload 3.90 or later and a database migration for the new collection and global.

Features

  • Message inbox collection with new, read and replied statuses
  • Settings global to open or close the form and tune length limits at runtime
  • Honeypot field, per-IP sliding-window rate limit and blocked keyword filtering
  • Admin inbox view with total, new, read and replied counts and period filters
  • Themeable ContactForm component styled through custom CSS properties
  • Optional SMTP email notifications configured from the admin settings

Use cases

  • Collect visitor enquiries on a website and triage them inside the Payload admin
  • Temporarily close the contact form or adjust spam rules without redeploying

From the author

Contact form plugin for Payload 3.x: a message inbox collection, runtime settings, spam protection (honeypot + rate limit), an admin inbox view, and a ready-to-use form component.

Installation

npm i @navanem/payload-contact

2

Stars

0

Forks

10

Open Issues

1 months ago

Last Updated

0

Weekly Downloads

v

npm Version

Dependencies

GitHub stars

20 since Sep 7

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

22/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/1274892328-root.svg)](https://payloaddirectory.dev/plugins/1274892328-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1274892328-root"><img src="https://payloaddirectory.dev/badge/1274892328-root.svg" alt="Payload Directory"></a>
Updated Nov 1, 2026Created Jun 20, 2026

README

@navanem/payload-contact

A contact-form plugin for Payload 3.x. It gives you a public form component, a validated submit endpoint with built-in spam protection, an admin inbox to read and triage messages, and a settings global to open/close the form and tune it at runtime — no redeploy required. No email is sent or exposed; messages are stored in your Payload admin.

Built by navanem — the same author as @navanem/payload-comments.

Features

  • Message inbox — a contact-messages collection (admin-read) with new / read / replied status, so the form acts as a triageable inbox.
  • Settings global — open or close the form, set min/max length, require a subject, block spam keywords, and set the success message, all at runtime.
  • Spam protection — a hidden honeypot field plus a per-IP sliding-window rate limit; blocked submissions are silently dropped (no useful signal to bots).
  • Admin Inbox view — a dedicated stats page (/admin/contact-inbox) with KPIs (total / new / read / replied), period filters and a recent-messages table.
  • Drop-in form — a styled, themeable <ContactForm /> client component.
  • Optional email notifications — opt-in SMTP delivery configured from the admin settings (no static email adapter required); off by default.

Installation

This plugin follows the same vendored model as @navanem/payload-comments: copy the source into your project (so the admin component paths resolve via your import map), or install from npm once published.

# copy the plugin source into your project
cp -r node_modules/@navanem/payload-contact/src src/plugins/payload-contact
# (or git clone and copy src/ in)

Then register the admin components in your generated app/(payload)/admin/importMap.js:

import { ContactInboxView } from '@/plugins/payload-contact/components/ContactInboxView'
import { ContactInboxNavLink } from '@/plugins/payload-contact/components/ContactInboxNavLink'

export const importMap = {
  // ...
  '@/plugins/payload-contact/components/ContactInboxView#ContactInboxView': ContactInboxView,
  '@/plugins/payload-contact/components/ContactInboxNavLink#ContactInboxNavLink': ContactInboxNavLink,
}

B. Install from npm

npm install @navanem/payload-contact

Quick start

1. Register the plugin

// payload.config.ts
import { contactPlugin } from '@navanem/payload-contact' // or '@/plugins/payload-contact'

export default buildConfig({
  // ...
  plugins: [
    contactPlugin({
      notificationEmail: '[email protected]',
    }),
  ],
})

2. Create the database tables

The plugin adds a contact-messages collection and a contact-settings global. Generate and run a migration:

payload migrate:create contact_plugin
payload migrate

The expected tables are contact_messages (with an enum_contact_messages_status enum and a payload_locked_documents_rels.contact_messages_id FK) and contact_settings.

3. Add the form to a page

import { ContactForm } from '@navanem/payload-contact/client'

export default function ContactPage() {
  return <ContactForm successMessage="Thanks — I'll get back to you by email." />
}

The form POSTs JSON to the plugin's endpoint:

POST /api/contact-api/submit   { name, email, subject?, message, company? }  -> { ok: true }

company is the honeypot field (kept hidden by the component). The endpoint path lives under /contact-api/* — not the collection slug — so it never collides with the contact-messages REST namespace.

Configuration

contactPlugin(options) — all options are optional:

OptionTypeDefaultDescription
enabledbooleantrueAccept new submissions (runtime-overridable via the settings global).
minLengthnumber10Minimum message length.
maxLengthnumber5000Maximum message length.
requireSubjectbooleanfalseRequire the subject field.
blockedKeywordsstring[][]A message containing any of these is dropped as spam.
notificationEmailstring''Stored for future email notifications (no email is sent without an adapter).
successMessagestringsensible defaultShown to the visitor after a successful submission.
rateLimit{ windowMs: number; max: number }{ 60000, 3 }Per-IP sliding-window limit.
messagesSlugstringcontact-messagesSlug for the inbox collection.
ipSaltstringCONTACT_IP_SALT envSalt for hashing IPs in the rate limiter.
disabledbooleanfalseNo-op (collection + global still registered so the schema stays stable).

Runtime settings

A Contact Settings global appears in the admin (group "Contact"). An admin can toggle the form on/off, change the min/max length, require a subject, edit the blocked keywords, and set the success message — applied immediately, no redeploy. The endpoint and the page fail open to the plugin options if the global has never been saved.

Admin inbox

  • Contact Messages — the collection list; open a message, change its status.
  • Contact Inbox (/admin/contact-inbox) — KPIs, period filters and a recent table.
  • The view is auth-guarded server-side (if (!req.user) return null) so message data never leaks into unauthenticated SSR output.

The form component

<ContactForm /> is a client component styled with a CSS module using --pc-* custom properties (with sensible defaults), so you can theme it by overriding those variables.

PropDefaultDescription
successMessagea default thank-youShown after submit.
disabledfalseRender a "closed" notice instead of the form.
endpoint/api/contact-api/submitSubmit URL.
className—Extra class on the root element.

Email notifications (optional)

Off by default — messages always land in the inbox. To also get emailed on each new message, open Contact Settings in the admin, expand Email notifications, tick "Send an email on each new message", and fill in the recipient + SMTP host/port/user/ password/TLS/from. An afterChange hook then sends via nodemailer on every new submission. The SMTP credentials live on an admin-read-only global, so they never reach the client.

Development

Use Node.js 22.12+ in the 22.x line, 24.x, or 26+, and pnpm 11.11.0 (the version used by CI).

pnpm install --frozen-lockfile
pnpm dev          # boots a sqlite-backed Payload admin with the plugin registered

The dev environment lives in dev/ (sqlite, schema auto-push — no migrations needed).

Testing

pnpm test         # run the vitest suite once
pnpm test:watch   # watch mode
pnpm build        # compile the plugin and copy its assets

Tests live in tests/ and exercise the plugin's pure and server logic through a fake payload object, plus the development collection's unlock rule through Payload's real access evaluator. No database is required to run them.

See SECURITY.md for the temporary Payload account-unlock mitigation and the remaining upstream advisory.

Documentation

License

MIT © navanem · www.navanem.com

Similar plugins