LogoLogo
  • Welcome to OneAuxilia Docx
  • UI Component
    • Overview
    • <OneAuxiliaProvider>
    • Authentication Components
      • <SignIn />
      • <SignUp />
      • <GoogleOneTap />
    • User Components
      • <UserButton />
      • <UserProfile />
    • Organization Components
      • <CreateOrganization />
      • <OrganizationProfile />
      • <OrganizationSwitcher />
      • <OrganizationList />
    • Control Components
      • <AuthenticateWithRedirectCallback />
      • <OneAuxiliaLoaded>
      • <OneAuxiliaLoading>
      • <Protect>
      • <MultisessionAppSupport>
      • <RedirectToSignIn />
      • <RedirectToSignUp />
      • <RedirectToUserProfile />
      • <RedirectToOrganizationProfile />
      • <RedirectToCreateOrganization />
      • <SignedIn>
      • <SignedOut>
    • Unstyled Components
      • <SignInButton>
      • <SignInWithMetamaskButton>
      • <SignUpButton>
      • <SignOutButton>
  • Quick Start
  • Users
    • Overview
    • Metadata
    • Delete User
  • Organization
    • Organization, Role and Permission
      • Overview
      • Role and Permission
      • Guides
        • Create Role and assign Permission
        • Verify the active user's permission
        • Reassign the Creator role
      • Building custom flow
    • Multi Tenant Setting
  • Application
    • Application
    • User Portal
  • Authentication
    • Setting
    • Social Connectors
    • Multi Factor
  • Customize
    • Branding
    • Sign Up vs Sign In
      • Overview
      • Configuration
        • Sign-up and Sign-in options
        • Session Option
        • Email and SMS templates
      • Social Connection
        • Overview
        • Social connections (OAuth)
        • Account Linking
        • Setup Social Account Linking
  • Development
    • API Key
    • Local Path
    • Custom JWT templates
    • Domain
    • Webhook
    • Backend Request
      • Overview
      • Making requests
        • Same-origin requests
        • Cross-origin requests
        • Customize your session token
      • Handling requests
        • Manual JWT verification
      • Session Management
  • SDK References
    • React
      • Overview
      • Guides
        • Add React Router
      • Client-side Helpers
        • useUser()
        • useOneAuxilia()
        • useAuth()
        • useSignIn()
        • useSignUp()
        • useSession()
        • useSessionList()
        • useOrganization()
        • useOrganizationList()
  • API References
    • Open API
  • industry reference
    • Ecommerce
    • Broadcasting
    • IoT
Powered by GitBook
On this page
  • useSession() returns
  • How to use the useSession() hook
  1. SDK References
  2. React
  3. Client-side Helpers

useSession()

The useSession() hook provides access to the current user's Session object, as well as helpers for setting the active session.

useSession() returns


isLoaded boolean

A boolean that is set to false until OneAuxilia loads and initializes.


isSignedIn boolean

A boolean that is set to true if the user is signed in.


session Session

Holds the current active session for the user.

How to use the useSession() hook

The following example demonstrates how to use the useSession() hook to access the SignIn object, which has the lastActiveAt property on it. The lastActiveAt property is used to display the last active time of the current session to the user.

home.tsx
import { useSession } from "@oneauxilia/oneauxilia-react";

export default function Home() {
  const { isLoaded, session, isSignedIn } = useSession();

  if (!isLoaded) {
    // Add logic to handle loading state
    return null;
  }
  if(!isSignedIn) {
    // Add logic to handle not signed in state
    return null;
  }

  return (
    <div>
      <p>This session has been active
      since {session.lastActiveAt.toLocaleString()}
      </p>
    </div>
  )
}
PrevioususeSignUp()NextuseSessionList()

Last updated 10 months ago