Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/slick-suns-hammer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@clerk/nextjs': minor
'@clerk/clerk-react': minor
'@clerk/vue': minor
---

Introduce `<RedirectToTask />` component
1 change: 1 addition & 0 deletions packages/nextjs/src/client-boundary/controlComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export {
Protect,
RedirectToSignIn,
RedirectToSignUp,
RedirectToTask,
RedirectToUserProfile,
AuthenticateWithRedirectCallback,
RedirectToCreateOrganization,
Expand Down
1 change: 1 addition & 0 deletions packages/nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export {
RedirectToOrganizationProfile,
RedirectToSignIn,
RedirectToSignUp,
RedirectToTask,
RedirectToUserProfile,
} from './client-boundary/controlComponents';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"RedirectToOrganizationProfile",
"RedirectToSignIn",
"RedirectToSignUp",
"RedirectToTask",
"RedirectToUserProfile",
"SignIn",
"SignInButton",
Expand Down
15 changes: 15 additions & 0 deletions packages/react/src/components/controlComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ export const RedirectToSignUp = withClerk(({ clerk, ...props }: WithClerkProp<Re
return null;
}, 'RedirectToSignUp');

export const RedirectToTask = withClerk(({ clerk }: WithClerkProp) => {
const { session } = clerk;

React.useEffect(() => {
if (!session) {
void clerk.redirectToSignIn();
return;
}

void clerk.__internal_navigateToTaskIfAvailable();
}, []);

return null;
}, 'RedirectToTask');

/**
* @function
* @deprecated Use [`redirectToUserProfile()`](https://clerk.com/docs/references/javascript/clerk#redirect-to-user-profile) instead.
Expand Down
1 change: 1 addition & 0 deletions packages/react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export {
RedirectToOrganizationProfile,
RedirectToSignIn,
RedirectToSignUp,
RedirectToTask,
RedirectToUserProfile,
SignedIn,
SignedOut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"RedirectToOrganizationProfile",
"RedirectToSignIn",
"RedirectToSignUp",
"RedirectToTask",
"RedirectToUserProfile",
"SignIn",
"SignInButton",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ exports[`root public exports > should not change unexpectedly 1`] = `
"RedirectToOrganizationProfile",
"RedirectToSignIn",
"RedirectToSignUp",
"RedirectToTask",
"RedirectToUserProfile",
"SignIn",
"SignInButton",
Expand Down
15 changes: 15 additions & 0 deletions packages/vue/src/components/controlComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ export const RedirectToSignUp = defineComponent((props: RedirectOptions) => {
return () => null;
});

export const RedirectToTask = defineComponent((props: RedirectOptions) => {
const { sessionCtx } = useClerkContext();

useClerkLoaded(clerk => {
if (!sessionCtx.value) {
void clerk.redirectToSignIn(props);
return;
}

void clerk.__internal_navigateToTaskIfAvailable();
});

return () => null;
});

/**
* @deprecated Use [`redirectToUserProfile()`](https://clerk.com/docs/references/javascript/clerk/redirect-methods#redirect-to-user-profile) instead.
*/
Expand Down
Loading