2.0.1 • Published 19 days ago

filsnap-adapter-react v2.0.1

Weekly downloads
-
License
(Apache-2.0 AND M...
Repository
github
Last release
19 days ago

filsnap-adapter-react

NPM Version License: MIT License Adapter

React hook for Filsnap.

Installation

pnpm install filsnap-adapter-react

Usage

import { FilsnapProvider } from 'filsnap-adapter-react'

const config = {
  network: 'testnet',
}

function Main() {
  return (
    <FilsnapProvider snap="npm:filsnap" config={config}>
      <App />
    </FilsnapProvider>
  )
}
import { useFilsnap } from 'filsnap-adapter-react'

function App() {
  const { isLoading, hasSnaps, isConnected, connect, account, error } =
    useFilsnap()

  if (isLoading) {
    return <div>Loading...</div>
  }

  if (!isConnected) {
    return <button onClick={() => connect()}>Connect to Filecoin Snap</button>
  }

  return <div>Connected to {account.address}</div>
}

Check out the demo for a working example and the API for more details.

Contributing

Read contributing guidelines here.

Open in GitHub Codespaces

License

Dual-licensed: MIT, Apache Software License v2, by way of the Permissive License Stack.

2.0.1

19 days ago

2.0.0

2 months ago

1.0.1

5 months ago

0.1.1

9 months ago

0.1.0

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago