@privy-io/wagmi-connector
v0.1.13
Published
A connector for Privy <> WAGMI.sh
Downloads
4,216
Readme
WAGMI 🤝 Privy
This package only supports WAGMI V1. Please use our new @privy-io/wagmi
library if you want to use WAGMI V2.
This plugin allows you to use WAGMI hooks with the Privy SDK. 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 as you would usually, and pass that to the PrivyWagmiConnector
instead:
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.