Function: ShowOnlyForUser()
ShowOnlyForUser(
__namedParameters):any
A component that conditionally renders content based on user authentication and authorization
Parameters
__namedParameters
Props
Returns
any
Description
This component provides a declarative way to control content visibility based on user authentication and specific user authorization. It uses pattern matching for clear and type-safe authorization logic.
Features:
- Conditional rendering based on authentication state
- User-specific authorization checks
- Type-safe pattern matching using ts-pattern
- Memoized result for performance optimization
- Client-side only execution ('use client')
Example
// Show content only for authenticated user
<ShowOnlyForUser>
<RestrictedContent />
</ShowOnlyForUser>
// Show content only for specific user
<ShowOnlyForUser userIdToCheckAuth="user-123">
<UserSpecificContent />
</ShowOnlyForUser>