@metamask/sdk-react-ui
TypeScript icon, indicating that this package has built-in type declarations

0.18.6 • Public • Published

MetaMask SDK React

The MetaMask SDK React UI allows developer an easier integration to the MetaMask SDK on React-based apps. On top of exporting the hooks from @metamask/sdk-react, it also provides wrapper around wagmi hooks and a basic UI button component to connect to MetaMask.

Getting Started

Install the ui sdk package:

yarn add @metamask/sdk-react-ui

Wrap your application in the provider

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import { MetaMaskUIProvider } from '@metamask/sdk-react-ui';

const root = ReactDOM.createRoot(
  document.getElementById('root') as HTMLElement
);

root.render(
  <React.StrictMode>
    <MetaMaskUIProvider sdkOptions={{
      dappMetadata: {
        name: "Demo UI React App",
      }
    }}>
      <App />
    </MetaMaskUIProvider>
  </React.StrictMode>
);

Use the SDK in your components:

import { MetaMaskButton } from '@metamask/sdk-react-ui';
import React, { useState } from 'react';

export const App = () => {
  return (
    <div className="App">
      <MetaMaskButton theme={'light'} color="white"></MetaMaskButton>
    </div>
  );
};

Look for more examples at https://github.com/MetaMask/metamask-sdk/tree/main/packages/examples

Contacts

Contact the MetaMask SDK team for a complimentary design optimization workshop here

Package Sidebar

Install

npm i @metamask/sdk-react-ui

Weekly Downloads

204

Version

0.18.6

License

none

Unpacked Size

25.1 MB

Total Files

65

Last publish

Collaborators

  • mcmire
  • nicholasellul
  • lgbot
  • naugtur
  • ritave
  • danfinlay
  • kumavis
  • rekmarks
  • metamaskbot
  • gudahtt
  • brad.decker
  • sethkfman