Skip to main content
The useAllNicknames hook returns an object containing all user nicknames in the current session. This is a read-only version of the useNicknames hook, perfect when you only need to display nicknames without the ability to modify them. If you need to read and modify nicknames, use useNicknames instead.

Basic Usage

Signature

Return Value

Record<string, string>
An object mapping user IDs to their nicknames for all users in the current React Together session. Users without custom nicknames may not appear in this object.

Examples

User Directory

Create a comprehensive user directory showing all participants:

Chat User Display

Show user nicknames in a chat interface:

Attendance Tracker

Track and display attendance for meetings or events:

Leaderboard Display

Show user rankings or scores using nicknames:

Best Practices

Data Access

  • Combine with useConnectedUsers - Use together to get complete user information
  • Handle missing nicknames - Always provide fallback display names for users without custom nicknames
  • Cache locally - The hook automatically handles caching, but avoid unnecessary re-renders

Performance

  • Read-only access - This hook is optimized for reading nicknames only
  • Efficient filtering - When displaying large user lists, consider pagination or filtering
  • Memo components - Use React.memo for user list items to prevent unnecessary re-renders

User Experience

  • Consistent display - Use the same fallback pattern throughout your app
  • Visual hierarchy - Highlight current user or important users in lists
  • Accessibility - Provide proper ARIA labels and semantic markup

Common Patterns

User Mentions

Reference users by their display names in text:

User Lists

Display comprehensive user information:

Message Attribution

Show who sent messages in chat interfaces:

TypeScript Support

This hook returns a strongly-typed object: