Package Exports
- helius-laserstream
Readme
@helius-laserstream
JavaScript/TypeScript client for Laserstream. Features automatic reconnection with slot tracking - if connection is lost, the client automatically reconnects and continues streaming from the last processed slot, ensuring no data is missed.
Installation
npm install helius-laserstreamUsage Example
import { subscribe, CommitmentLevel, LaserstreamConfig, SubscribeRequest } from 'helius-laserstream';
async function main() {
const config: LaserstreamConfig = {
apiKey: 'your-api-key',
endpoint: 'your-endpoint',
};
const request: SubscribeRequest = {
transactions: {
client: {
accountInclude: ['TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'],
accountExclude: [],
accountRequired: [],
vote: false,
failed: false
}
},
commitment: CommitmentLevel.CONFIRMED,
// Empty objects for unused subscription types
accounts: {},
slots: {},
transactionsStatus: {},
blocks: {},
blocksMeta: {},
entry: {},
accountsDataSlice: [],
};
// Client handles disconnections automatically:
// - Reconnects on network issues
// - Resumes from last processed slot
// - Maintains subscription state
await subscribe(
config,
request,
async (data) => {
console.log('Received update:', data);
},
async (error) => {
console.error('Error:', error);
}
);
}
main().catch(console.error);Runtime Support
Node.js
node your-app.jsBun
bun your-app.jsThe library uses Node-API (NAPI) bindings which are supported natively by both runtimes.
API Reference
Core Functions
subscribe(config, request, onData, onError)- Main streaming functionshutdownAllStreams()- Gracefully shutdown all active streamsgetActiveStreamCount()- Get number of active streams
Types
LaserstreamConfig- Configuration interfaceSubscribeRequest- Stream subscription requestCommitmentLevel- Solana commitment levels (PROCESSED, CONFIRMED, FINALIZED)
Performance
This library is built with Rust NAPI bindings, providing significant performance improvements:
4.6x faster throughput compared to the standard Yellowstone gRPC client.
Key Performance Features
- Zero-copy message passing
- Minimal JavaScript overhead
- Native async/await support
- Optimized memory usage
- High-performance Rust implementation
License
MIT