Use This When
- you need a backend to keep a SQL view of on-chain events or account state
- you want to expose indexed chain data through app APIs
- you need filtering, joins, and pagination over chain data that would be awkward to do directly from RPC
- you are building an analytics pipeline, read model, or historical replay service
Choosing A Package
Use this table to decide which package fits your indexing use case.| Package | Use it when | What it gives you |
|---|---|---|
@thru/thru-sdk | You need direct chain reads, simple streaming, or ad-hoc RPC queries without persistence. | Typed RPC client for accounts, transactions, and chain state. No storage or checkpointing. |
@thru/replay | You need an ordered backfill-plus-live feed for analytics, ETL, or event processing without managing your own database writes. | Historical replay with live handoff, reconnect handling, and typed async iterators. You bring your own storage. |
@thru/indexer | You need a persistent backend indexer with Postgres storage, resumable checkpoints, and optional generated read APIs. | Stream definitions, Drizzle schema generation, checkpoint management, and mountable Hono routes. Built on top of @thru/replay. |
@thru/indexer. If you only need an ordered feed and want full control over where and how data lands, use @thru/replay directly. If you only need to read current chain state without indexing history, @thru/thru-sdk is sufficient.
Core Packages
| Package | Role |
|---|---|
@thru/indexer | Defines streams, manages checkpoints, writes rows to Postgres, and can mount generated API routes. |
@thru/replay | Supplies the historical-plus-live replay layer and the ChainClient used by the indexer runtime. |
The Shape Of A Thru Indexer
Most projects follow this pattern:- define one or more event or account streams
- export the resulting stream tables in the Drizzle schema
- construct
new Indexer(...)with a DB client,ChainClientfactory, and stream arrays - optionally mount generated routes for those streams in a Hono app
Start Here
Build an Indexer
Build a working token indexer and learn the production concerns for a real backend service.
Streams
Learn how event streams and account streams differ, and how to write each safely.
Running the Indexer
See the runtime architecture, tech-stack assumptions, and the indexer boot flow.
Querying Indexed Data
Query stream tables directly or expose them through generated routes.
Next Steps
- Read Build an Indexer for the first successful end-to-end setup and production guidance.
- Move to Streams when you need to add or customize event or account parsing.
- Use Running the Indexer when you are wiring runtime config, checkpoints, migrations, or deployment shape.
- Use Querying Indexed Data once data is landing in Postgres.
Related
- Web SDKs Overview for the full list of web packages.
@thru/indexerreference for the complete API surface.@thru/replayreference for replay primitives and client details.