Documentation Index
Fetch the complete documentation index at: https://mintlify.com/hypertekorg/hyperstack/llms.txt
Use this file to discover all available pages before exploring further.
useHyperstack
The primary hook for connecting to a Hyperstack and accessing its views and instructions.Signature
Parameters
The stack definition containing views and instructions
Override the stack’s embedded WebSocket URL (useful for local development)
Return Value
The hook returns aStackClient object with:
Type-safe view hooks for all views defined in your stack
Instruction executors and mutation hooks for all instructions in your stack
Direct access to the Zustand store (for advanced use cases)
The underlying HyperStack client instance
Current connection state:
'connected' | 'connecting' | 'disconnected' | 'error'Convenience boolean for
connectionState === 'connected'True while establishing initial connection
Connection error if any
Basic Example
View Hooks
View hooks provide type-safe access to real-time data from your Hyperstack. They automatically subscribe to updates and re-render when data changes.State Views
For views withmode: 'state', use the use() hook:
Parameters
Optional key object to fetch a specific entity
Configuration options:
enabled?: boolean- Enable/disable the subscription (default:true)initialData?: T- Initial data while loadingschema?: Schema<T>- Zod schema for validationrefreshOnReconnect?: boolean- Re-fetch on reconnection
Return Value
The fetched entity, or
undefined if loading or not foundTrue while fetching initial data
Error object if subscription failed
Manually trigger a re-subscription
List Views
For views withmode: 'list', use the use() or useOne() hooks:
Fetch Multiple Items
Fetch Single Item
useOne() convenience method:
List Parameters
Optional view key for partitioned data
Client-side filtering conditions:Supports:
gte, lte, gt, lt for numeric comparisonsServer-side filters (sent in subscription request)
Client-side limit (applied after filtering)
Number of items to fetch (1 for single item)
Number of items to skip (for pagination)
Zod schema for validation. Invalid items are filtered out.
Schema Validation
Use Zod schemas to validate and type data:Advanced Patterns
Conditional Fetching
Client-Side Filtering
Pagination
Manual Refresh
Zustand Integration
Access the underlying Zustand store for custom selectors:Next Steps
Mutations
Learn how to execute instructions
Examples
See complete working examples