<UserButton />
component
The <UserButton />
component is used to render the familiar user button UI popularized by Google.
Clerk is the only provider with multi-session support, allowing users to sign into multiple accounts at once and switch between them. For multi-session apps, the <UserButton />
automatically supports instant account switching, without the need of a full page reload. For more information, see the dedicated guide on multi-session apps.
Properties
All props are optional.
- Name
afterMultiSessionSingleSignOutUrl
(deprecated)- Type
string
- Description
The full URL or path to navigate to after a signing out from a currently active account in a multi-session app. Deprecated - Move
afterSignOutUrl
to<ClerkProvider/>
.
- Name
afterSignOutUrl
(deprecated)- Type
string
- Description
The full URL or path to navigate to after a successful sign-out. Deprecated - Move
afterSignOutUrl
to<ClerkProvider/>
.
- Name
afterSwitchSessionUrl
- Type
string
- Description
The full URL or path to navigate to after a successful account change in a multi-session app.
- Name
appearance
- Type
Appearance | undefined
- Description
Optional object to style your components. Will only affect Clerk components and not Account Portal pages.
- Name
defaultOpen
- Type
boolean
- Description
Controls whether the
<UserButton />
should open by default during the first render.
- Name
showName
- Type
boolean
- Description
Controls if the user name is displayed next to the user image button.
- Name
signInUrl
- Type
string
- Description
The full URL or path to navigate to when the Add another account button is clicked. It's recommended to use the environment variable instead.
- Name
userProfileMode
- Type
'modal' | 'navigation'
- Description
Controls whether clicking the Manage your account button will cause the
<UserProfile />
component to open as a modal, or if the browser will navigate to theuserProfileUrl
where<UserProfile />
is mounted as a page.
Defaults to:'modal'
.
- Name
userProfileProps
- Type
object
- Description
Specify options for the underlying
<UserProfile />
component.
For example:{additionalOAuthScopes: {google: ['foo', 'bar'], github: ['qux']}}
.
- Name
userProfileUrl
- Type
string
- Description
The full URL or path leading to the user management interface.
Usage with frameworks
In the following example, <UserButton />
is mounted inside a header component, which is a common pattern on many websites and applications. When the user is signed in, they will see their avatar and be able to open the popup menu.
Usage with JavaScript
The following methods available on an instance of the Clerk
class are used to render and control the <UserButton />
component:
The following examples assume that you have followed the quickstart in order to add Clerk to your JavaScript application.
mountUserButton()
Render the <UserButton />
component to an HTML <div>
element.
- Name
node
- Type
HTMLDivElement
- Description
The
<div>
element used to render in the<UserButton />
component
- Name
props?
- Type
UserButtonProps
- Description
The properties to pass to the
<UserButton />
component
unmountUserButton()
Unmount and run cleanup on an existing <UserButton />
component instance.
- Name
node
- Type
HTMLDivElement
- Description
The container
<div>
element with a rendered<UserButton />
component instance.
Customization
To learn about how to customize Clerk components, see the customization documentation.
You can also add custom actions and links to the <UserButton />
menu.
Feedback
Last updated on