Skip to main content

Event Tracking

This example demonstrates how to subscribe to SDK events to build real-time UI updates, progress indicators, and transaction link displays.

Overview

The Mina SDK provides an event system that emits updates throughout the bridge execution process:
  • Quote updates
  • Execution started
  • Step changes (approval, swap, bridge, deposit)
  • Transaction sent/confirmed
  • Deposit started/completed
  • Execution completed/failed
  • Overall status changes

Available Events

Subscribing to Events

React Hook for Event Tracking

Progress Tracker Component

Cleanup on Unmount

Always clean up event listeners when components unmount to prevent memory leaks:
CleanupExample.tsx

Using useTransactionStatus Hook

For simpler status tracking, use the built-in hook:
SimpleStatusTracking.tsx

Best Practices

When working with SDK events:
  1. Always unsubscribe from events on component unmount
  2. Use refs to track mutable state in event handlers
  3. Avoid subscribing/unsubscribing on every render
  4. Handle all terminal states (completed, failed)
  5. Show transaction links as soon as available
  6. Provide clear progress feedback to users

Next Steps

Error Handling

Handle execution errors

Full Integration

Complete bridge widget