React Hooks
Custom React hooks for authentication and Agent Hustle integration.
📖 Related Documentation
useAgentHustle Hook
Custom React hook that manages Agent Hustle state across pages with localStorage persistence. Handles independent authentication, settings, messages, tools, attachments, and provides both streaming and non-streaming chat methods.
🔐 Independent Authentication
This hook uses its own instance of the EmblemAuthSDK, independent from any global authentication system. Users authenticate specifically for Agent Hustle functionality, with separate session management.
Full Hook Implementation
Usage Example
📋 State Management
- •
settings- API configuration - •
messages- Chat history - •
isLoading- Request status - •
error- Error messages - •
selectedTools- Active tools - •
attachments- File uploads - •
debugMode- Debug toggle - •
isAuthenticated- Auth status - •
session- User session
⚡ Actions
- •
sendMessage()- Standard chat - •
sendMessageStream()- Streaming - •
updateSettings()- Config updates - •
clearMessages()- Reset history - •
toggleDebugMode()- Debug toggle - •
addAttachment()- File management - •
updateSelectedTools()- Tool config - •
openAuthModal()- Start auth flow - •
logout()- End session - •
getToolCategories()- Fetch tools
Hook Features
Persistence
- • Automatic localStorage sync
- • Cross-page state sharing
- • Error-safe JSON handling
Performance
- • useCallback optimizations
- • Efficient state updates
- • Memory leak prevention
- • Memoized client instances
Authentication
- • Independent auth SDK instance
- • Automatic session restoration
- • API key management
- • Global singleton pattern
🔧 Integration Notes
• This hook is completely independent from any global authentication system
• Users must authenticate specifically for Agent Hustle functionality
• State persists across page reloads and navigation
• Streaming and non-streaming chat methods are both supported
• Built-in error handling and loading states
• Automatic API key management from vault sessions