useFetchConnectionsCount
Overview
The useFetchConnectionsCount hook fetches the total number of established connections for the current logged-in user. This is useful for displaying connection counts in user profiles, dashboard statistics, or navigation badges.
Usage Example
Advanced Usage with State Management
Usage in Profile Dashboard
Usage with Real-time Updates
Usage in Navigation Badge
Usage with Achievement System
Parameters & Returns
Parameters
The hook returns a function that takes no parameters.
Returns
The function returns a Promise that resolves to a ConnectionCountResponse object containing:
The total number of established connections
Error Handling
The hook will throw errors in the following cases:
- No project is specified
- No user is logged in
- Network connection issues
Use Cases
This hook is commonly used in:
Profile & Dashboard Features:
- User profile connection counters
- Dashboard statistics widgets
- Professional networking metrics
Navigation & UI:
- Navigation badge counts
- Menu item indicators
- Status bar information
Gamification:
- Achievement systems based on connection counts
- Progress tracking for networking goals
- Milestone celebrations
Analytics & Reporting:
- User engagement metrics
- Network growth tracking
- Social proof displays
- Caching: Consider caching the result to avoid frequent API calls
- Auto-refresh: Implement periodic updates for dynamic displays
- Optimistic Updates: Update count immediately after connection actions
- Error Handling: Provide graceful fallbacks for loading states
useFetchConnections - Get detailed connection information with pagination
useFetchConnectionsCountByUserId - Get connection count for any user
useConnectionManager - Comprehensive connection state management
useFetchConnectionStatus - Check connection status with specific users