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
Option | Description | Default |
---|---|---|
network | Bitcoin network to connect to | MAINNET |
dataSources | Array of data sources to use | Default data source |
walletProviders | Array of wallet providers to support | All available providers |
autoConnect | Whether to auto-connect to the last used wallet | true |