npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@omnisat/lasereyes-react

v0.0.44

Published

`@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.

Downloads

2,293

Readme

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.