Files
payload-feature-flags/dev/README.md
Bas van den Aakster a6712666af Remove custom API endpoints in favor of Payload's native REST API
- Removed custom endpoint handler and endpoints directory
- Removed enableApi configuration option from plugin
- Updated client hooks to use Payload's native collection API
- Updated documentation to reflect API changes
- Updated view component to handle Payload API response format

The plugin now uses Payload CMS's built-in REST API for the feature-flags collection, which provides standard query syntax, pagination, and automatic access control enforcement.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-03 14:17:11 +02:00

2.2 KiB

Demo Environment

Simple demo for testing the feature flags plugin.

Quick Start

pnpm install
pnpm dev
# Visit http://localhost:3000

URLs:

Login

Admin: dev@payloadcms.com / test (full access)
Editor: editor@payloadcms.com / test123 (limited access)
User: user@payloadcms.com / test123 (read-only)

What's included

Homepage: Shows feature flag status and demo content
Admin Panel: Manage feature flags and users
Sample Data: One test feature flag ready to use

Testing the Plugin

  1. Check the homepage - See the feature flag in action
  2. Login to admin - Use admin credentials above
  3. Toggle the flag - Go to Feature Flags collection
  4. Refresh homepage - See content appear/disappear

Plugin Config

payloadFeatureFlags({
  enableRollouts: true,    // Percentage rollouts
  enableVariants: true,    // A/B testing
  defaultValue: false,     // New flags start disabled
  // + custom fields and permissions
})

API Testing

The plugin uses Payload's native REST API:

# Get all flags
curl http://localhost:3000/api/feature-flags

# Query specific flag
curl 'http://localhost:3000/api/feature-flags?where[name][equals]=new-feature'

# Get only enabled flags
curl 'http://localhost:3000/api/feature-flags?where[enabled][equals]=true'

Database

Uses in-memory MongoDB - no setup needed! Data resets on each restart.

Creating New Flags

  1. Login to /admin/collections/feature-flags
  2. Click "Create New"
  3. Add name, description, and toggle enabled/disabled
  4. Check the homepage to see it working

Need Help?

  • Check the console for error messages
  • Make sure port 3000 is available
  • Try logging in as admin user

Next Steps

Ready to use this in your project?

  1. Add to your project: Copy the plugin config
  2. Customize: Add your own fields and permissions
  3. Go live: Use a real MongoDB database
  4. Monitor: Track how your flags perform

This demo gives you everything needed to test feature flags with zero setup.