npm.io
0.0.21 • Published 6 months ago

@omnisat/lasereyes-ui

Licence
Version
0.0.21
Deps
10
Size
361 kB
Vulns
0
Weekly
0

Lasereyes Modal

Lasereyes Modal makes it easy for developers to integrate Bitcoin wallet connection flows into their applications with minimal setup. It builds on top of the @omnisat/lasereyes library to provide a convenient modal-based UI.

Version license

Wallets Supported:

  • Leather
  • Magic Eden
  • OKX
  • Orange Wallet
  • OYL
  • Unisat
  • Wizz
  • Phantom
  • Xverse
  • Sparrow

Installation

You could install the Lasereyes package which contains everything lasereyes:

npm install @omnisat/lasereyes
# OR
yarn add @omnisat/lasereyes

Or you could install the Lasereyes UI package which contains the modal and the styles:

npm install @omnisat/lasereyes-ui
# OR
yarn add @omnisat/lasereyes-ui

If you installed the lasereyes package, then you can access lasereyes-ui through lasereyes/ui

import { LaserEyesModalProvider } from '@omnisat/lasereyes/ui';

Make sure your project uses React 18+.

Usage

The simplest way to integrate this library is by wrapping your application with <LaserEyesModalProvider>. This automatically wraps your app with <LaserEyesProvider>, allowing all child components to access the wallet state.

You can then use:

  • <ConnectWalletButton> — A pre-styled button to trigger the modal.
  • useLaserEyesModal — A hook for manually controlling the modal.
  • <ConnectWalletModal> — A component to manually render the modal.
Example Usage
import { ConnectWalletButton, LaserEyesModalProvider } from '@omnisat/lasereyes/ui';
import '@omnisat/lasereyes/ui/style.css';

function App() {
  return (
    <LaserEyesModalProvider>
      <div>
        <h1>Welcome</h1>
        <ConnectWalletButton />
      </div>
    </LaserEyesModalProvider>
  );
}

export default App;
Using useLaserEyesModal

If you want to create a custom button to open the modal, use the useLaserEyesModal hook:

import { useLaserEyesModal } from '@omnisat/lasereyes/ui';

function CustomWalletButton() {
  const { showModal } = useLaserEyesModal();

  return <button onClick={showModal}>Connect Wallet</button>;
}
Controlling the Modal Directly

You can also use <ConnectWalletModal> directly:

import { useState } from 'react';
import { ConnectWalletModal } from '@omnisat/lasereyes/ui';

function ManualModalExample() {
  const [isOpen, setIsOpen] = useState(false);

  return (
    <>
      <button onClick={() => setIsOpen(true)}>Connect</button>
      <ConnectWalletModal open={isOpen} onClose={() => setIsOpen(false)} />
    </>
  );
}

API Reference

useLaserEyesModal
interface LaserEyesModalContext {
  isOpen: boolean;
  isLoading: boolean;
  showModal: () => void;
  hideModal: () => void;
  config: LaserEyesModalConfig;
  setConfig: (config: LaserEyesModalConfig) => void;
}
<ConnectWalletModal>
Prop Type Description
open boolean Controls whether the modal is visible.
onClose function Called when the modal should close.

Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discuss Laser Eyes Modal on GitHub

Contributing

Contributions to Laser Eyes Modal are greatly appreciated! If you're interested in contributing to this open source project, please read the Contributing Guide before submitting a pull request.

Sponsors

If you find Laser Eyes Modal useful or use it for work, please consider sponsoring Laser Eyes. Thank you


Ecosystem Partnerships

UTXO Management Ordinals Bot

L1F BLIFE

Start-Up Sponsors

Seize CTRL Sats Ventures Leather Orange Wallet


Become A Sponsor