0.36.1 • Published 11 months ago

@fuels/react v0.36.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
11 months ago

discord

⚡️ Fuel Wallet React Hooks

The Fuel Wallet React Hooks provide a set of hooks to seamless integrate the Fuel Wallet browser extension with any React JS or Next JS project.

Installation

npm install fuels @fuel-wallet/react

Note that the fuels package is also required as a dependency for better integration with other applications built using the Fuels TS SDK.

Usage

Setup the provider

Adding the providers on the upper level of the application that will use the hooks.

import { FuelProvider } from '@fuel-wallet/react';

import { App } from './App';

ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
  <React.StrictMode>
    <FuelProvider>
      <App />
    </FuelProvider>
  </React.StrictMode>,
);

Connecting to Wallet

import { useState } from 'react';
import {
  useConnect,
  useConnectors,
  useDisconnect,
  useIsConnected,
} from '@fuel-wallet/react';

export default function App() {
  const [connector, setConnector] = useState('');
  const { connectors } = useConnectors();
  const { connect } = useConnect();
  const { disconnect } = useDisconnect();
  const { isConnected } = useIsConnected();

  return (
    <div
      style={{
        display: 'flex',
        flexDirection: 'column',
        gap: 10,
        padding: 10,
        maxWidth: 300,
      }}
    >
      <select
        onChange={(e) => {
          console.log(e.target.value);
          setConnector(e.target.value);
        }}
      >
        <option value="">Select a connector</option>
        {connectors.map((c) => (
          <option key={c.name} value={c.name}>
            {c.name}
          </option>
        ))}
      </select>
      <button disabled={!connector} onClick={() => connect(connector)}>
        Connect to {connector}
      </button>
      <button disabled={!connector} onClick={() => disconnect()}>
        Disconnect from {connector}
      </button>
      <p>{isConnected ? 'Connected' : ''}</p>
    </div>
  );
}

Please visit our docs to get started using the Fuel Wallet React Hooks.

Additionally, you can check up the Fuel Wallet React Hooks reference for more details.

📜 License

This repo is licensed under the Apache-2.0 license. See LICENSE for more information.

0.36.1

11 months ago

0.36.1-main-b0ef68f

11 months ago

0.36.0

11 months ago

0.36.0-main-57dc2f6

11 months ago

0.35.2-main-9d5e004

11 months ago

0.35.2-main-46000eb

11 months ago

0.35.1-main-d6e12c9

11 months ago

0.32.0-main-9a20224

12 months ago

0.32.0

12 months ago

0.33.0-main-aa757db

12 months ago

0.29.0

12 months ago

0.29.6

12 months ago

0.29.5

12 months ago

0.29.4

12 months ago

0.29.3

12 months ago

0.29.2

12 months ago

0.29.1

12 months ago

0.33.0

12 months ago

0.32.0-main-5a2cfe3

12 months ago

0.31.3-main-1ffb4b5

12 months ago

0.32.1-main-58d0388

12 months ago

0.31.6-main-450b612

12 months ago

0.31.5-main-11f468c

12 months ago

0.30.1

12 months ago

0.30.0

12 months ago

0.31.6

12 months ago

0.31.5

12 months ago

0.31.4

12 months ago

0.31.3

12 months ago

0.31.2

12 months ago

0.31.5-main-64c291f

12 months ago

0.31.1

12 months ago

0.31.0

12 months ago

0.31.5-main-28022d0

12 months ago

0.34.0-main-cdac8d4

12 months ago

0.35.0-main-5c3d337

12 months ago

0.31.1-main-fa88dca

12 months ago

0.31.2-main-d40b0b7

12 months ago

0.30.2-main-296748c

12 months ago

0.34.2-main-9c0923b

12 months ago

0.31.5-main-4eecdf3

12 months ago

0.34.1-main-b0708e3

12 months ago

0.31.4-main-9c1db2e

12 months ago

0.34.2

12 months ago

0.34.1

12 months ago

0.34.0

12 months ago

0.33.1-main-cd36eda

12 months ago

0.35.1

11 months ago

0.35.0

12 months ago

0.31.0-main-4303a90

12 months ago

0.28.1

1 year ago

0.28.0

1 year ago

0.27.1

1 year ago

0.27.0

1 year ago

0.26.0

1 year ago

0.20.0

1 year ago

0.25.0

1 year ago

0.23.0

1 year ago

0.21.0

1 year ago

0.24.0

1 year ago

0.22.0

1 year ago

0.19.0

1 year ago

0.18.1

1 year ago

0.18.0

1 year ago

0.17.0

2 years ago

0.16.0

2 years ago

0.15.3

2 years ago

0.15.2

2 years ago

0.15.1

2 years ago