@loop/cms
Shared Payload CMS configuration consumed by any Loop app running Payload. Provides generic collections, access rules, hooks, and Clerk SSO authentication.
Installation
pnpm add @loop/cmsCollections
Generic collections reusable across Loop brands:
import { Users, Media, Pages, BlogPosts, FAQs, HelpArticles, Testimonials, ResearchPapers, COAs } from '@loop/cms/collections';| Collection | Description |
|---|---|
Users | CMS admin users (auto-created from Clerk) |
Media | Uploaded files and images |
Pages | Static pages |
BlogPosts | Blog articles with rich text |
FAQs | Frequently asked questions |
HelpArticles | Help center content |
Testimonials | Customer testimonials |
ResearchPapers | Research paper references |
COAs | Certificates of Analysis |
Access Rules
import { isAuthenticated, isAdmin, isAdminOrEditor, isStaff, publicReadStaffWrite, adminOnlyField, editorField } from '@loop/cms/access';
// Use in collection config
const MyCollection = {
slug: 'my-collection',
access: {
read: publicReadStaffWrite,
create: isAdminOrEditor,
update: isAdminOrEditor,
delete: isAdmin,
},
fields: [
{ name: 'title', type: 'text' },
adminOnlyField({ name: 'internalNotes', type: 'textarea' }),
],
};Hooks
Cache Revalidation
import { makeRevalidateHook } from '@loop/cms/hooks';
const MyCollection = {
slug: 'my-collection',
hooks: {
afterChange: [makeRevalidateHook('my-collection')],
},
};When a document is created/updated, this hook calls revalidateTag('my-collection') to purge the Next.js cache.
Knowledge Base Sync
import { syncCOAToKnowledgeBase, removeCOAFromKnowledgeBase } from '@loop/cms/hooks';Automatically syncs COA content to the vector knowledge base for Luna AI search.
Clerk Auth Strategy
import { clerkStrategy } from '@loop/cms/auth/clerk-strategy';Integrates Clerk SSO with Payload CMS authentication. Users are auto-provisioned in Payload on first login based on their Clerk publicMetadata.adminRole.
Used By
@loop/cms is exclusively used by the admin application:
- @loop/admin — Payload CMS collections, access rules, hooks, and authentication