Updated Privy provider for bnb

This commit is contained in:
yoginawaka 2025-03-17 16:15:53 +00:00
parent 208b741175
commit b7a65a987c

View File

@ -1,43 +1,45 @@
'use client'; // Add this at the top to mark as Client Component 'use client';
import { PrivyProvider } from '@privy-io/react-auth'; import { PrivyProvider } from '@privy-io/react-auth';
import { ReactNode } from 'react'; import { ReactNode , useEffect } from 'react';
import { toSolanaWalletConnectors } from '@privy-io/react-auth/solana'; // Replace this with any of the networks listed at https://github.com/wevm/viem/blob/main/src/chains/index.ts
import {bsc} from 'viem/chains';
export function Providers({ children }: { children: ReactNode }) { export function Providers({ children }: { children: ReactNode }) {
const solanaConnectors = toSolanaWalletConnectors({ useEffect(() => {
shouldAutoConnect: false, localStorage.removeItem('privy:embedded-wallet:iframe-ready');
}); localStorage.removeItem('privy:embedded-wallet:ready');
}, []);
return ( return (
<PrivyProvider <PrivyProvider
appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID || ''} appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID || ''}
config={{ config={{
appearance: { "appearance": {
accentColor: "#6A6FF5", "accentColor": "#6A6FF5",
theme: "#FFFFFF", "theme":"#FFFFFF",
showWalletLoginFirst: false, "showWalletLoginFirst": false,
logo: "https://auth.privy.io/logos/privy-logo.png", "logo": "https://auth.privy.io/logos/privy-logo.png",
walletChainType: 'solana-only', "walletChainType": 'ethereum-only',
walletList: ['phantom'] "walletList": ['metamask', 'wallet_connect', 'coinbase_wallet', 'rabby_wallet', 'cryptocom','safe']
}, },
externalWallets: { "loginMethods": [
solana: { "email",
connectors: solanaConnectors "wallet"
},
},
loginMethods: [
'email',
'wallet'
], ],
embeddedWallets: { "embeddedWallets": {
createOnLogin: 'all-users', "createOnLogin": "all-users",
requireUserPasswordOnCreate: false, "requireUserPasswordOnCreate": false,
showWalletUIs: true "showWalletUIs": true
}, },
"mfa": {
"noPromptOnMfaRequired": false
},
defaultChain: bsc,
supportedChains: [bsc]
}} }}
> >
{children} {children}
</PrivyProvider> </PrivyProvider>
); );
} }