Autoconnect & Session UX
Restore wallet sessions smoothly without surprising users.
Search across all documentation pages
Restore wallet sessions smoothly without surprising users.
<WalletProvider wallets={wallets} autoConnect>When to reach for this:
"use client";
import { useWallet } from "@solana/wallet-adapter-react";
export function WalletGate({ children }: { children: React.ReactNode }) {
const { connected, connecting } = useWallet();
if (connecting) return <p>Restoring wallet session…</p>;
if (!connected) return <p>Connect wallet to view portfolio</p>;
return <>{children}</>;
}What this demonstrates:
| Alternative | Use When | Don't Use When |
|---|---|---|
| Manual connect only | High-security admin apps | Consumer apps |
| Email + embedded wallet | Web2 onboarding | Sovereign wallet narrative |
Match RPC URL, wallet network, and program IDs to one cluster.
Use @solana/kit 7.0.0 for new frontend code.
Surfpool 0.12.0 or devnet with faucet SOL.
confirmed for UX; finalized for high-value reads.
Providers in client layout; reads can be server-side.
Show retry; never assume approval.
Compute budget instructions on congested mainnet.
Use Mobile Wallet Adapter for React Native apps.
Never expose server keypairs to the browser.
Regenerate typed clients in CI.
Stack versions: This page was written for Agave 4.1.1, Solana CLI 3.0.10, Anchor 0.32.1, anchor-lang 0.32.1, Rust 1.91.1, @solana/kit 7.0.0, Surfpool 0.12.0, and LiteSVM 0.6.x.
Reviewed by Chris St. John·Last updated Jul 16, 2026