UNPKG

@privy-io/wagmi-connector

Version:

A connector for Privy <> WAGMI.sh

36 lines (25 loc) 1.65 kB
## WAGMI 🤝 Privy ![wagmi-privy](https://user-images.githubusercontent.com/3359083/234168805-833660eb-e9f0-4b75-9e51-476cab621d8d.png) **This package only supports WAGMI V1. Please use our new [`@privy-io/wagmi`](https://www.npmjs.com/package/@privy-io/wagmi) library if you want to use WAGMI V2.** This plugin allows you to use WAGMI hooks with the [Privy SDK](https://docs.privy.io). To integrate, simply wrap your components like so. (example next.js code below) (the below shows using goerli and mainnet) The idea is that you first [configure WAGMI](https://wagmi.sh/react/providers/configuring-chains) as you would usually, and pass that to the `PrivyWagmiConnector` instead: ```tsx import {goerli, mainnet} from '@wagmi/chains'; import type {AppProps} from 'next/app'; import {configureChains} from 'wagmi'; import {publicProvider} from 'wagmi/providers/public'; import {PrivyProvider} from '@privy-io/react-auth'; import {PrivyWagmiConnector} from '@privy-io/wagmi-connector'; const configureChainsConfig = configureChains([mainnet, goerli], [publicProvider()]); export default function App({Component, pageProps}: AppProps) { return ( <PrivyProvider appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID as string}> <PrivyWagmiConnector wagmiChainsConfig={configureChainsConfig}> <Component {...pageProps} /> </PrivyWagmiConnector> </PrivyProvider> ); } ``` Then, in your application, feel free to use WAGMI hooks like `useAccount`, `useSignMessage`, `useEnsName`, ... Please do not use the `useConnect` hook to connect, but rather use `{login} = usePrivy()`. Privy controls the session and syncs it with WAGMI.