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
  • Properties
  • SignOutOptions
  • Usage
  • Basic usage
  • Custom usage
  • Multi-session usage
  1. UI Component
  2. Unstyled Components

<SignOutButton>

The <SignOutButton> component is a button that signs a user out. By default, it is a <button> tag that says Sign Out, but it is completely customizable by passing children.

Properties


asChild? boolean

For Astro only: If true, the <SignOutButton> component will render its children as a child of the component.


redirectUrl? string

The redirect URL to navigate to after sign out is complete.


signOutOptions? SignOutOptions

Options for signing out. Includes sessionId which if passed, signs the user out of a specific session. Useful for multi-session applications.


children? React.ReactNode

Children you want to wrap the <SignOutButton> in.

SignOutOptions

The type of the signOutOptions prop for the component is defined as follows:


sessionId? string

The ID of a specific session to sign out of. Useful for multi-session applications.


redirectUrl? string

The redirect URL to navigate to after sign out is complete.

Usage

Basic usage

app/page.js
import { SignOutButton } from '@oneauxilia/nextjs'

export default function Home() {
  return <SignOutButton />
}
example.js
import { SignOutButton } from '@oneauxilia/oneauxilia-react'

export default function Example() {
  return <SignOutButton />
}
pages/index.js
import { SignOutButton } from '@oneauxilia/remix'

export default function Home() {
  return <SignOutButton />
}
pages/index.astro
---
import { SignOutButton } from '@oneauxilia/astro/components'
---

<SignOutButton />

Custom usage

You can create a custom button by wrapping your own button, or button text, in the <SignOutButton> component.

app/page.js
import { SignOutButton } from '@oneauxilia/nextjs'

export default function Home() {
  return (
    <SignOutButton>
      <button>My custom button</button>
    </SignOutButton>
  )
}
example.js
import { SignOutButton } from '@oneauxilia/oneauxilia-react'

export default function Example() {
  return (
    <SignOutButton>
      <button>My custom button</button>
    </SignOutButton>
  )
}
pages/index.js
import { SignOutButton } from '@oneauxilia/remix'

export default function Home() {
  return (
    <SignOutButton>
      <button>My custom button</button>
    </SignOutButton>
  )
}

You must pass the asChild prop to the <SignOutButton> component if you are passing children to it.

pages/index.astro
---
import { SignOutButton } from '@oneauxilia/astro/components'
---

<SignOutButton asChild>
  <button>My custom button</button>
</SignOutButton>

Multi-session usage

Sign out of all sessions

Clicking the <SignOutButton> component signs the user out of all sessions. This is the default behavior.

Sign out of a specific session

You can sign out of a specific session by passing in a sessionId to the signOutOptions prop. This is useful for signing a single account out of a multi-session (multiple account) application.

In the following example, the sessionId is retrieved from the useAuth() hook. If the user is not signed in, the sessionId will be null, and the user is shown the component. If the user is signed in, the user is shown the component, which when clicked, signs the user out of that specific session.

app/page.tsx
'use client'

import { SignInButton, SignOutButton, useAuth } from '@oneauxilia/nextjs'

export default function Home() {
  const { sessionId } = useAuth()

  if (!sessionId) {
    return <SignInButton />
  }

  return <SignOutButton signOutOptions={{ sessionId }} />
}
example.js
import { SignInButton, SignOutButton, useAuth } from '@oneauxilia/oneauxilia-react'

export default function Home() {
  const { sessionId } = useAuth()

  if (!sessionId) {
    return <SignInButton />
  }

  return <SignOutButton signOutOptions={{ sessionId }} />
}
pages/index.js
import { SignInButton, SignOutButton, useAuth } from '@oneauxilia/remix'

export default function Home() {
  const { sessionId } = useAuth()

  if (!sessionId) {
    return <SignInButton />
  }

  return <SignOutButton signOutOptions={{ sessionId }} />
}
Previous<SignUpButton>NextQuick Start

Last updated 6 months ago