Skip to main content

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.

Stacks are the client-side interface to your deployed Hyperstack stream. They provide type-safe access to views, transactions, and helpers.

What is a Stack?

A stack definition includes:
  • Views - Real-time data subscriptions organized by entity
  • Instructions - Transaction handlers for writing to the blockchain
  • URL - WebSocket endpoint for your deployed stream
Stacks are defined once and used across your application to access data and submit transactions.

Quick Start

import { HyperStack } from 'hyperstack-typescript';
import { MyStack } from './stack';

// Connect to the stack
const client = await HyperStack.connect(MyStack);

// Access views
const tokens = await client.views.tokens.list.get();

// Subscribe to updates
for await (const data of client.views.tokens.list.use()) {
  console.log('Tokens updated:', data);
}

Stack Structure

Stacks are organized into logical groups:
const MyStack = {
  name: 'my-app',
  url: 'wss://my-stream.hyperstack.dev',
  views: {
    tokens: {
      list: { mode: 'list', view: 'Token/list' },
      state: { mode: 'state', view: 'Token/state' },
    },
    trades: {
      list: { mode: 'list', view: 'Trade/list' },
    },
  },
  instructions: {
    swap: SwapInstruction,
    createToken: CreateTokenInstruction,
  },
};

Connection States

Stacks maintain a WebSocket connection with the following states:
  • disconnected - Not connected
  • connecting - Establishing connection
  • connected - Active connection
  • reconnecting - Attempting to reconnect after disconnect
  • error - Connection failed
const client = await HyperStack.connect(MyStack);

// Check connection state
console.log(client.connectionState); // 'connected'

// Monitor connection changes
client.onConnectionStateChange((state, error) => {
  console.log('Connection:', state);
  if (error) console.error('Error:', error);
});

Connection Options

Customize connection behavior:
const client = await HyperStack.connect(MyStack, {
  url: 'wss://custom-url.com', // Override default URL
  autoReconnect: true,         // Enable auto-reconnect
  reconnectIntervals: [1000, 2000, 4000], // Backoff intervals
  maxReconnectAttempts: 5,     // Max reconnect attempts
  maxEntriesPerView: 10000,    // Limit cached entries
  flushIntervalMs: 100,        // Batch update interval
});

Next Steps

Views

Learn about state and list views

Subscriptions

Subscribe to real-time data

Transactions

Execute blockchain transactions

Build docs developers (and LLMs) love