0.0.29 • Published 8 months ago

@omnisat/lasereyes-react v0.0.29

Weekly downloads
-
License
-
Repository
-
Last release
8 months ago

lasereyes-react

@omnisat/lasereyes-react is a React-specific package built on top of lasereyes-core. It provides React hooks, context providers, and wallet icon components to make it easy to integrate Bitcoin wallet support into React applications.

This package simplifies the interaction between your React app and various Bitcoin wallets, allowing you to focus on building dApps with a seamless user experience.

Key Concepts

Provider

The @omnisat/lasereyes-react package exports a Provider component that wraps your React application, providing access to wallet functionality throughout your app via React context.

Example of setting up the provider:

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

function App() {
  return (
    <LaserEyesProvider network="mainnet">
      {/* Rest of your application */}
    </LaserEyesProvider>
  );
}

Hooks

@omnisat/lasereyes-react provides hooks to interact with wallets within your React components. The most commonly used hook is useLaserEyes, which allows you to access the connected wallet and its state.

Example of using the useLaserEyes hook:

// must be a child of a component that is wrapped with LaserEyesProvider

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

function WalletInfo() {
  const { address, connect } = useLaserEyes();

  return (
    <div>
      {address ? (
        <p>Connected: {address}</p>
      ) : (
        <button onClick={connect}>Connect Wallet</button>
      )}
    </div>
  );
}

Icons

@omnisat/lasereyes-react also exports SVG wallet icons as React components, making it easy to include visual wallet indicators in your app.

Example of using a wallet icon:

import { UnisatLogo } from '@omnisat/lasereyes-react';

function WalletDisplay() {
  return <UnisatLogo size={size} className={className} variant={variant} />;
}

or you could use the WalletIcon component to display a wallet icon based on the wallet's name:

import { WalletIcon, UNISAT, XVERSE } from '@omnisat/lasereyes-react';

const WalletConnectPage = () => {
  return (
    <div>
      {[UNISAT, XVERSE].map((walletName) => (
        <WalletIcon key={walletName} walletName={walletName} size={45} className={"mx-4"} />
      ))
    </div>
  );
};

Features

  • React Hooks: Easily manage wallet connections and state in your components.
  • Provider Component: Wrap your app with the LaserEyesProvider to enable wallet access across your React tree with useLaserEyes.
  • Wallet Icons: Use pre-built wallet icons as React components for visual integration.

Usage

Set up @omnisat/lasereyes-react by wrapping your app with the LaserEyesProvider and using the provided hooks (like useWallet) to interact with wallets.

Contributing

Contributions are welcome! Feel free to submit pull requests or open issues in the GitHub repository.

License

@omnisat/lasereyes-react is MIT licensed.

the ai release notes generator is so cool..

0.0.25

8 months ago

0.0.26

8 months ago

0.0.27

8 months ago

0.0.28

8 months ago

0.0.29

8 months ago

0.0.23

8 months ago

0.0.24

8 months ago

0.0.21

8 months ago

0.0.22

8 months ago

0.0.20

8 months ago

0.0.17

8 months ago

0.0.18

8 months ago

0.0.19

8 months ago

0.0.10

9 months ago

0.0.12

9 months ago

0.0.13

9 months ago

0.0.14

9 months ago

0.0.15

9 months ago

0.0.9

9 months ago

0.0.16

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.4-rc.3

9 months ago

0.0.4-rc.2

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago