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

@keyban/sdk-react

v0.2.0

Published

Keyban SDK React simplifies the integration of Keyban's MPC wallet in React apps with TypeScript support, flexible storage, and Ethereum blockchain integration.

Downloads

19

Readme

Keyban SDK React

Overview

The Keyban SDK React is designed to integrate Keyban's MPC wallet solution seamlessly into React applications. It simplifies the use of decentralized wallets by providing developers with an easy-to-use set of components, hooks, and utilities, fully compatible with React's ecosystem.

Key Features

  • TypeScript Support: Fully typed for safer and more efficient development.
  • Flexible Storage: KeybanLocalStorage is provided as the default storage for user data. Additional storage options will be available in future updates.
  • Blockchain Support: Currently supports Ethereum's Sepolia testnet (Mainnet coming soon).
  • Error Handling: Built-in support for react-error-boundary for graceful error handling.
  • Suspense Compatibility: Supports React's Suspense API for loading asynchronous data seamlessly.
  • Bundling: Efficient bundling with tsup, optimizing development and production builds.

Installation

npm install @keyban/sdk-react

Basic Example

This example shows how to set up the SDK with basic components, integrating with React's error boundaries and Suspense API.

import React from "react";
import ReactDOM from "react-dom";
import { ErrorBoundary } from "react-error-boundary";
import { KeybanProvider, KeybanChain, KeybanLocalStorage } from "@keyban/sdk-react";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <KeybanProvider
    appId="your-keyban-app-id"
    accessTokenProvider={async () => "user's access token"}
    chain={KeybanChain.Sepolia}
    storage={KeybanLocalStorage}
  >
    <ErrorBoundary fallbackRender={({ error }) => <pre>{error.message}</pre>}>
      <React.Suspense fallback="Loading...">
        <MyWallet />
      </React.Suspense>
    </ErrorBoundary>
  </KeybanProvider>,
);

function MyWallet() {
  const [account, accountError] = useKeybanAccount({ suspense: true });
  if (accountError) throw accountError;

  const [balance, balanceError] = useKeybanAccountBalance(account, { suspense: true });
  if (balanceError) throw balanceError;

  return (
    <div>
      Your account balance: <FormattedBalance balance={balance} />
    </div>
  );
}

Hooks and Components

The SDK provides key React hooks and components to simplify wallet and balance management:

  • useKeybanAccount: Hook to retrieve account details.
  • useKeybanAccountBalance: Hook to fetch the account's balance.
  • FormattedBalance: Component to format and display balances in a readable format.

Supported Blockchains

Currently, the SDK supports testnets only:

  • Sepolia Testnet: KeybanChain.Sepolia

Mainnet support will be added in a future release.

Custom Storage and Signing

Developers can implement their own storage and signing mechanisms if needed. In this release, the SDK comes with KeybanLocalStorage by default. More advanced storage options are planned.

Bundlers

Vite.js

When using Vite.js, you might encounter a known issue regarding WebAssembly (WASM) modules in development mode. To resolve this, exclude the @keyban/ecdsa-wasm-client package from optimized dependencies by updating your vite.config.ts as follows:

import { defineConfig } from "vite";

export default defineConfig({
  optimizeDeps: {
    exclude: ["@keyban/ecdsa-wasm-client"],
  },
});

Documentation

For more details and advanced usage, refer to the official Keyban API Reference Portal.