Setup Guide

Basic Setup

Get started with LaserEyes in your React application with this step-by-step guide.

Prerequisites

React

v16.8 or higher required for hooks support

Node.js

v14 or higher for modern JavaScript features

Package Manager

npm, yarn, or pnpm for dependency management

Setup Guide

1

Installation

First, install the LaserEyes packages using your preferred package manager:

npm install @omnisat/lasereyes-core @omnisat/lasereyes-react
2

Provider Setup

Wrap your application with the LaserEyes provider to enable wallet functionality:

import { LaserEyesProvider } from '@omnisat/lasereyes-react'
import { MAINNET } from '@omnisat/lasereyes-core'

function App() {
  return (
    <LaserEyesProvider
      config={{
        network: MAINNET,
        // Other configuration options
      }}
    >
      <YourApp />
    </LaserEyesProvider>
  )
}
3

Using the Hook

Access LaserEyes functionality in your components using the useLaserEyes hook:

import { useLaserEyes } from '@omnisat/lasereyes-react'

function WalletStatus() {
  const { 
    connect, 
    disconnect, 
    address, 
    isConnected, 
    isConnecting 
  } = useLaserEyes()

  if (isConnecting) {
    return <div>Connecting...</div>
  }

  if (isConnected) {
    return (
      <div>
        <p>Connected: {address}</p>
        <button onClick={disconnect}>Disconnect</button>
      </div>
    )
  }

  return (
    <button onClick={connect}>Connect Wallet</button>
  )
}

Configuration Options

OptionDescriptionDefault
networkBitcoin network to connect toMAINNET
dataSourcesArray of data sources to useDefault data source
walletProvidersArray of wallet providers to supportAll available providers
autoConnectWhether to auto-connect to the last used wallettrue