import { Callout, Button } from '@vegaprotocol/ui-toolkit'; import { useVegaWallet } from '@vegaprotocol/react-helpers'; import { useEffect } from 'react'; import { rest } from '../lib/connectors'; import { LocalStorage } from '@vegaprotocol/storage'; export function Index() { // Get keys from vega wallet immediately useEagerConnect(); const { publicKey, publicKeys, selectPublicKey } = useVegaWallet(); return (
With a longer explaination

Vega wallet

{publicKey &&

Current: {publicKey.pub}

} {publicKeys?.length && ( )}

Public keys

{JSON.stringify(publicKeys, null, 2)}
); } export default Index; function useEagerConnect() { const { connect } = useVegaWallet(); useEffect(() => { // Might be safer to store connector name and eager connect using that if (LocalStorage.getItem('vega_wallet_token')) { connect(rest); } }, [connect]); }