• Returns current Session data.

    Use this hook to determine if the user is authenticated or not.

    function Page() {
    const { data, error, loading } = useSession();

    if (loading) return <Loader />;

    if (error) return <p>Something went wrong.</p>;

    switch (data.type) {
    case SessionType.Anonymous:
    // data is a AnonymousSession
    return <Login />;

    case SessionType.JustWallet:
    // data is a WalletOnlySession
    return <MyWallet address={data.address} />;

    case SessionType.WithProfile:
    // data is a ProfileSession
    return <MyProfile profile={data.profile} />;

    default:
    return <p>Something went wrong.</p>;
    }
    }

    Parameters

    • args: {
          suspense: true;
      }
      • suspense: true

    Returns SuspenseResult<Session>

  • Returns current Session data.

    This signature supports React Suspense.

    function Page() {
    const { data } = useSession({ suspense: true });

    switch (data.type) {
    case SessionType.Anonymous:
    // data is a AnonymousSession
    return <Login />;

    case SessionType.JustWallet:
    // data is a WalletOnlySession
    return <MyWallet address={data.address} />;

    case SessionType.WithProfile:
    // data is a ProfileSession
    return <MyProfile profile={data.profile} />;

    default:
    return <p>Something went wrong.</p>;
    }
    }

    Further session data updates will NOT trigger a suspense.

    Returns ReadResult<Session, UnspecifiedError>