Removes misleading warning that appeared during Next.js SSR:
- Client components are initially rendered on server where window is undefined
- This is expected behavior and doesn't require a warning
- Now silently falls back to relative URLs during SSR
- Properly uses window.location.origin once hydrated on client
The hooks now work seamlessly in:
- Pure client-side apps
- Next.js with SSR/SSG
- Server components (with explicit serverURL)
- Client components (auto-detects after hydration)
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Addresses critical issues identified in code review:
1. Server-Side Environment Handling:
- Add warning when serverURL is not provided in SSR/SSG environments
- Falls back to relative URLs with console warning
- Prevents silent failures in server-side rendering
2. Race Condition Fix:
- Use useRef for initialFlags to prevent re-creating fetchFlags on every render
- Removes initialFlags from useCallback dependencies
- Prevents excessive re-renders and potential infinite loops
These improvements ensure better stability and reliability in both
client-side and server-side environments.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Makes client hooks work outside of Payload Admin UI context by:
- Adding FeatureFlagOptions parameter to all hooks for configuration
- Using window.location.origin as default serverURL when in browser
- Removing @payloadcms/ui dependency from client hooks
- Allowing custom serverURL, apiPath, and collectionSlug configuration
This fixes the webpack error "_payloadcms_ui__WEBPACK_IMPORTED_MODULE_1__.b() is undefined"
when using the hooks in frontend applications.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 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>