<UserProfile />
A full-featured account management component
Overview
The <UserProfile/>
component is used to render a beautiful, full-featured account management UI that allows users to manage their profile and security settings. Learn more about the <UserProfile/> component, what it does, and how it is used by reading our User Profile component guide.
Usage
1import {2ClerkProvider,3RedirectToSignIn,4SignedIn,5SignedOut,6UserProfile7} from "@clerk/nextjs";89function MyApp({ pageProps }) {10return (11<ClerkProvider {...pageProps}>12<SignedIn>13{/* Signed in users will see their user profile */}14<UserProfile />15</SignedIn>16<SignedOut>17<RedirectToSignIn />18</SignedOut>19</ClerkProvider>20);21}2223export default MyApp;
1import {2ClerkProvider,3SignedIn,4SignedOut,5UserProfile,6RedirectToSignIn,7} from "@clerk/clerk-react";8import { useNavigate, BrowserRouter } from "react-router-dom";910function AppWithRoutes() {11// Get navigate method from the router12// This example uses 'react-router-dom'13const navigate = useNavigate();1415return (16// Pass the navigate method to ClerkProvider17<ClerkProvider18publishableKey="clerk-pub-key"19navigate={(to) => navigate(to)}20>21{/* Signed in users will see their user profile,22unauthenticated users will be redirected */}23<SignedIn>24<UserProfile />25</SignedIn>26<SignedOut>27<RedirectToSignIn />28</SignedOut>29</ClerkProvider>30);31}3233function App() {34return (35<BrowserRouter>36<AppWithRoutes />37</BrowserRouter>38);39}4041export default App;
1<html>2<body>3<div id="user-profile"></div>45<script>6const el = document.getElementById("user-profile");7// Mount the pre-built Clerk UserProfile component8// in an HTMLElement on your page.9window.Clerk.mountUserProfile(el);10</script>11</body>12</html>
Interested in using path-based routing instead of the default hash-based routing? Check out the example code here.
Props
Name | Type | Description |
---|---|---|
appearance? | Theme | Controls the overall look and feel |
routing? | RoutingStrategy | The routing strategy for your pages. Supported values are: - hash (default): Hash based routing. - path: Path based routing. - virtual: Virtual based routing. |
path? | string | The path where the component is mounted when path-based routing is used. -e.g. /user-profile. This prop is ignored in hash and virtual based routing. |
additionalOAuthScopes? | Record<OAuthProvider, string[]> | Specify additional scopes per OAuth provider that your users would be prompted to approve if not already done so e.g. |
Customization
The <UserProfile/>
component can be highly customized through the appearance prop and can be styled using CSS Modules, Tailwind, inline CSS objects, or global CSS.