https://solana-labs.github.io/wallet-adapter/example/ How do I keep my wallet connected and refresh the page without reconnecting?
1 Answer
Solana wallet adapter has the property autoConnect we have to set it to true. and Also have to set cookies on the front end if needed. here is an example.
<ConnectionProvider endpoint="https://api.devnet.solana.com">
<WalletProvider
wallets={wallets}
autoConnect={
cookies.get('_sToken') &&
cookies.get('_Platform') === 'solana'
? true
: false
}
></WalletProvider>
</ConnectionProvider>
-
Wallet Adapter will use localstorage to save the selected wallet, so if that's sufficient (it probably is unless you need to send the selected wallet to your server) you just need to set
autoConnect
and don't need to worry about cookies.– Callum MCommented Oct 24 at 12:58