Skip to content

chore(clerk-react,vue,nextjs): Introduce <RedirectToTask /> component #6416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 29, 2025

Conversation

LauraBeatris
Copy link
Member

@LauraBeatris LauraBeatris commented Jul 28, 2025

Description

Introduce a <RedirectToTask /> component to be used on root /{signInUrl}/tasks pages.

If an app, using auth.protect() has a custom sign-in page (not using <SignIn />), it must create a pge for the /tasks route in which auth.protect() redirects to on pending session status.

On that page, it should redirect to where tasks are resolved with <RedirectToTask /> - it'll either use taskUrls or default to the Clerk.signInUrl

// app/layout.tsx 
<ClerkProvider taskUrls={{ 'select-organization': '/onboarding/select-organization' }} />
clerkMiddleware((..) => if (isProtectedPage) auth.protect())
// app/sign-in/tasks/page.tsx
function SignInTasks() { 
  return <RedirectToTask /> 
}

Caveats:

It's not possible to customize the /tasks path atm. We'll cover that use case on the next iteration.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features
    • Introduced a new component, RedirectToTask, now available in Next.js, React, and Vue packages. This component enables seamless redirection to a relevant task or sign-in page based on session status.

@LauraBeatris LauraBeatris self-assigned this Jul 28, 2025
Copy link

changeset-bot bot commented Jul 28, 2025

🦋 Changeset detected

Latest commit: dbe6b31

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
@clerk/nextjs Minor
@clerk/clerk-react Minor
@clerk/vue Minor
@clerk/chrome-extension Patch
@clerk/elements Patch
@clerk/clerk-expo Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/nuxt Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jul 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ⬜️ Skipped (Inspect) Jul 28, 2025 8:54pm

@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 26d308b to 211922a Compare July 28, 2025 19:48
@LauraBeatris LauraBeatris changed the title chore(react,vue,nextjs): Introduce <RedirectToTask /> component chore(clerk-react,vue,nextjs): Introduce <RedirectToTask /> component Jul 28, 2025
@LauraBeatris LauraBeatris requested a review from a team July 28, 2025 19:51
@LauraBeatris LauraBeatris marked this pull request as ready for review July 28, 2025 19:51
@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 211922a to 5f5e065 Compare July 28, 2025 19:55
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

📝 Walkthrough

Walkthrough

A new component named <RedirectToTask /> was introduced to the @clerk/nextjs, @clerk/clerk-react, and @clerk/vue packages. The React version uses the withClerk HOC to access the Clerk session and runs an effect on mount that redirects unauthenticated users to the sign-in page or navigates authenticated users to a task if available via an internal Clerk method. The Vue version uses useClerkContext and useClerkLoaded hooks to perform similar logic once Clerk is loaded. The component renders nothing and was added alongside existing redirect components. Corresponding exports were added to relevant modules in each package.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bd78fab and dbe6b31.

📒 Files selected for processing (1)
  • packages/nextjs/src/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/nextjs/src/index.ts

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jul 28, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6416

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6416

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6416

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6416

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6416

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6416

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6416

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6416

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6416

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6416

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6416

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6416

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6416

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6416

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6416

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6416

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6416

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6416

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6416

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6416

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6416

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6416

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6416

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6416

commit: dbe6b31

@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 08f93b9 to 6ea967e Compare July 28, 2025 20:08
@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 6ea967e to 17e2406 Compare July 28, 2025 20:13
@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 17e2406 to 6c4bd5d Compare July 28, 2025 20:25
@LauraBeatris LauraBeatris force-pushed the laura/add-redirect-to-task-component branch from 6c4bd5d to 3faf5ac Compare July 28, 2025 20:36
Copy link
Member

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we don't add something to auth.protect() similar the unauthenticatedUrl that we offer ? Feels weird that we need to redirect to the signInUrl only to be redirected somewhere else.

@LauraBeatris
Copy link
Member Author

LauraBeatris commented Jul 29, 2025

I've talked with @panteliselef about this comment

There's still room for improvement on the DX for the tasks resolution page. We could provide a component that would play nicely with a catchall route:

<ClerkProvider taskUrls={{ root: '/onboarding', 'select-organization': '/onboarding/select-organization' }} />

// app/onboarding/page.tsx
export default function OnboardingPage(){ 
  return <PendingTask />
}

I'll think more about this flow later. Will merge this PR for now to unblock the after-auth release and update the docs with it.

@LauraBeatris LauraBeatris merged commit f6375f0 into main Jul 29, 2025
36 checks passed
@LauraBeatris LauraBeatris deleted the laura/add-redirect-to-task-component branch July 29, 2025 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants