Skip to content

No first-class session / auth-status hook; useAccount().isConnected is not the auth source of truth #259

Description

@jayeshbhole

Summary

There is no first-class hook to read whether the user is authenticated. wagmi's useAccount().isConnected is not the auth source of truth, which leads consumers to gate their UI on the wrong signal.

Details

wagmi reconnects from its localStorage cache on load and reports isConnected: true even when the ZeroDev wallet session is absent or expired. The real auth state is the session in the connector's zustand store (ZeroDevWalletState.session), but there's no public hook exposing it.

Gating on isConnected produces two failure modes:

  1. App treats a user as logged in with no valid session → the next sign / send fails.
  2. Clicking a stale "connect" button on an already-connected connector throws:
    Connector already connected. Version: @wagmi/core@2.22.1.

To get the correct state today, you have to reach into internals:

const connector = getZeroDevConnector(config)
const store = await getZeroDevStore(connector)
const session = store.getState().session // not a documented/public hook
store.subscribe(...)

Ask

Ship a public useSession() / useIsAuthenticated() hook (returning { session, isAuthenticated, ready }), and document clearly that wagmi isConnected is not the auth source of truth for this connector.

Environment

@zerodev/wallet-react@0.0.1-alpha.26, wagmi 2.19.5, mode 7702.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions