BigBlocks

Sync Terminal

Monospace event log for blockchain sync activity with colour-coded severity levels, auto-scroll, and connection status indicator

Installation

bunx shadcn@latest add https://registry.bigblocks.dev/r/sync-terminal.json

Usage

Pass an array of events and optional status to display a live sync log. The terminal auto-scrolls to the latest event and caps the internal buffer at maxEvents.

import { SyncTerminal, type SyncEvent } from "@/components/blocks/sync-terminal"
 
export function Dashboard() {
  const [events, setEvents] = useState<SyncEvent[]>([])
 
  return (
    <SyncTerminal
      events={events}
      status={{ blockHeight: 850123, connected: true }}
      maxEvents={500}
    />
  )
}

Props

SyncTerminal

PropTypeDefaultDescription
eventsSyncEvent[]requiredEvents to display
statusSyncStatus--Sync status shown in the header
maxEventsnumber200Max events in the buffer
titlestring"Sync Log"Header title
showTimestampsbooleantrueShow timestamps in each line
showSourcebooleantrueShow source labels in each line
autoScrollbooleantrueAuto-scroll to latest event
classNamestring--Additional CSS classes

SyncEvent

interface SyncEvent {
  timestamp: number
  source: string
  level: "log" | "warn" | "error" | "success"
  message: string
}

SyncStatus

interface SyncStatus {
  blockHeight: number
  connected: boolean
}

Hook

useSyncTerminal manages the event buffer and auto-scroll ref.

import { useSyncTerminal } from "@/components/blocks/sync-terminal"
 
function CustomTerminal() {
  const { events, bottomRef } = useSyncTerminal({
    events: rawEvents,
    maxEvents: 300,
    autoScroll: true,
  })
 
  return (
    <div className="overflow-y-auto font-mono text-xs">
      {events.map((e, i) => (
        <div key={i}>{e.message}</div>
      ))}
      <div ref={bottomRef} />
    </div>
  )
}