hyperstack-react
v0.4.3
Published
React SDK for the Hyperstack Solana developer platform
Downloads
3,749
Maintainers
Readme
Hyperstack React SDK
React SDK for real-time Solana program data streaming from Hyperstack.
Built on top of hyperstack-typescript, the pure TypeScript core SDK.
Installation
npm install hyperstack-reactNot using React? Use
hyperstack-typescriptdirectly for Vue, Svelte, Node.js, or vanilla JavaScript.
Usage
Basic Setup
import { HyperstackProvider, useHyperstack, defineStack } from 'hyperstack-react';
const myStack = defineStack({
// Your stack configuration
});
function App() {
return (
<HyperstackProvider config={{ /* your config */ }}>
<MyComponent />
</HyperstackProvider>
);
}
function MyComponent() {
const stack = useHyperstack(myStack);
// Use your stack
}Core Features
- Real-time Data Streaming: Subscribe to Solana program state changes
- React Integration: Hooks-based API for easy integration with React applications
- State Management: Built-in state management with Zustand
- Type Safety: Full TypeScript support with comprehensive type definitions
- View Definitions: Create state and list views for your data
- Transaction Handling: Define and execute transactions with hooks
- Single Item Queries: Type-safe single item fetching with
take: 1oruseOne()
API
Providers
HyperstackProvider- Root provider for Hyperstack configuration
Hooks
useHyperstack- Main hook for accessing stack functionalityuseHyperstackContext- Access the runtime context directly
View Methods
.use()- Subscribe to view data (returnsT[]for lists,Tfor state).use({ take: 1 })- Subscribe to single item with type narrowing (returnsT | undefined).useOne()- Convenience method for single item queries (returnsT | undefined)
Factory Functions
defineStack- Define a new stack configurationcreateStateView- Create a state viewcreateListView- Create a list viewcreateRuntime- Create a runtime instance
Utilities
ConnectionManager- Manage WebSocket connections
Relationship with hyperstack-typescript
This package depends on and re-exports the core hyperstack-typescript package. The core SDK provides:
HyperStack- Main client classConnectionManager- WebSocket connection handlingEntityStore- State management- AsyncIterable-based streaming APIs
The React SDK adds:
HyperstackProvider- React context provideruseHyperstack- Main hook for accessing stacksuseConnectionState- Connection monitoring hookdefineStack,createStateView,createListView- React-friendly factories
If you need low-level access, you can import directly from the core:
import { HyperStack, ConnectionManager } from 'hyperstack-react';
// or
import { HyperStack, ConnectionManager } from 'hyperstack-typescript';License
MIT
Author
HyperTek
