Clerk logo

Clerk Docs

Ctrl + K
Go to clerkstage.dev

<RedirectToUserProfile />

Navigate to the user profile URL

Overview

Rendering a <RedirectToUserProfile/> component will navigate to the user profile URL which has been configured in your application instance. You can find the configuration on the Paths page.

This component will use the custom navigate function from the <ClerkProvider/> component if one is given - otherwise, it will trigger a full page reload with the new URL location.

Usage

Make sure you've followed the installation guide for Clerk React before running the snippets below.

The example below shows a page which is normally accessible by authenticated users. All other visitors (unauthenticated users) will get redirected to the sign in page.

The <SignedIn/> and <SignedOut/> components work together as a conditional, allowing the <RedirectToUserProfile /> component to be rendered only for authenticated users.

1
import {
2
ClerkProvider,
3
SignedOut,
4
SignedIn,
5
RedirectToSignIn,
6
RedirectToUserProfile,
7
} from "@clerk/clerk-react";
8
9
function App() {
10
return (
11
<ClerkProvider publishableKey="clerk-pub-key">
12
{/* Signed in users will get redirected to
13
the user profile page */}
14
<SignedIn>
15
<RedirectToUserProfile />
16
</SignedIn>
17
18
<SignedOut>
19
<RedirectToSignIn />
20
</SignedOut>
21
</ClerkProvider>
22
);
23
}
24
25
export default App;

Props

This component accepts no props.

Was this helpful?

Clerk © 2023