Skip to content

Wallet Connection State Persistence Across Page Refresh #467

Description

@Kingsman-99

Description

Refreshing the page disconnects the Freighter wallet, forcing users to re-approve the connection on every visit. The last connected wallet's public key should be cached and the connection silently re-established on mount where the user has previously granted permission.

Technical Context

src/hooks/useWallet.ts should call freighter.isConnected() on mount and, if true, skip the approval popup by calling freighter.getPublicKey() directly. The cached public key is stored in sessionStorage (not localStorage) to avoid persisting across closed browser tabs. src/context/WalletContext.tsx (new or existing) exposes connection state app-wide via a React context. src/components/wallet/WalletConnect.tsx reflects the cached state immediately without a loading flash.

Acceptance Criteria

  • After granting connection permission, a hard page refresh reconnects the wallet without a new popup
  • The connected wallet address is displayed in the navigation bar within 500 ms of page load
  • Closing the browser tab clears the cached key from sessionStorage so the next session starts fresh
  • If Freighter is not installed, a polite prompt with an install link appears instead of an error
  • Disconnecting via the UI clears the sessionStorage entry and renders the connect button
  • All CI checks (npm test, npm run build, ESLint/TypeScript) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions