Access ControlAlpha
Protect your documentation with JWT or OAuth to control who can access pages and API references.
Quick Start
Add accessControl to your docs.json:
Claims and Groups
Use the groupsClaim field to read user groups for access control. How groups are provided depends on the provider type.
| Claim | Type | Required | Description |
|---|---|---|---|
sub | string | Yes | User identifier |
exp | number | Yes | Expiration (Unix timestamp in seconds) |
iat | number | Yes | Issued-at time |
groups | string[] | For group access | Groups/roles (key name must match groupsClaim) |
Example JWT payload:
Auth server example (Node.js):
Security Model
| Layer | Protection | Platform |
|---|---|---|
Layer 1 (default) | SSR exclusion + client-side auth. Content not in HTML source. | Any static host |
Layer 2 (deploy) | Server-side JWT verification. Content never served to unauthorized. | Node.js, Netlify, Vercel, Cloudflare |
Page-Level Access
Frontmatter
Override access on individual pages:
| Field | Effect |
|---|---|
public: true | Always public, even if defaultAccess is "protected" |
public: false | Always protected, even if defaultAccess is "public" |
accessGroups: ["admin"] | Requires membership in at least one listed group |
Pattern Rules
Match pages by glob pattern in docs.json:
Rules are evaluated in order — first match wins.
Evaluation Priority
- Frontmatter (highest) —
public/accessGroupsin page metadata - Pattern rules —
rulesarray indocs.json - Default access (lowest) —
defaultAccess: "public" | "protected"
Deploy Adapters
For production deployments, enable server-side protection:
With node-edge, xyd build generates a server.mjs in your build output:
The server verifies JWT signatures (HS256), checks access rules on every request, and returns 302 for unauthorized users.
Environment Variables
| Variable | Required | Description |
|---|---|---|
AUTH_SECRET | Yes (for JWT) | JWT signing secret (≥32 characters) |
PORT | No | Server port (default: 3000) |
Session Configuration
Login Page
xyd provides a built-in login page at /login. Customize it:
Feature Availability
Some features behave differently when you enable authentication. Protected pages are automatically excluded from search results, sidebar navigation, sitemap, and llms.txt for unauthorized users.
| Feature | Public (no auth) | Fully authenticated | Partially authenticated |
|---|---|---|---|
Search | Full support | Filtered by auth state | Filtered by auth state |
Sidebar | Full support | Filtered by groups | Filtered by groups |
Sitemap | Full support | Protected pages excluded | Protected pages excluded |
llms.txt | Full support | Protected pages excluded | Protected pages excluded |
Prev/Next links | Full support | Filtered by access | Filtered by access |
HTML source | Full content | Empty shell (SSR exclusion) | Protected pages: empty shell |
JS chunks | All accessible | Blocked by deploy adapter | Protected chunks blocked |
Examples
Show your support! Star us on GitHub ⭐️