feat(ui): add a replace option to the component router - #9683
Conversation
🦋 Changeset detectedLatest commit: 23a75d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (8)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
Included review availability: 9 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour. 📝 WalkthroughWalkthroughThe change adds optional Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This adds optional history-entry replacement to router navigation while retaining existing navigation behavior by default. The documented forwarding and hash-navigation coverage indicate no remaining merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 7 files. (1 skipped: 1 unsupported.)
Warning Linked repositories: Your configuration references 7 linked repositories, but your current plan allows 5. Analyzed Repository analysis: Could not refresh Comment |
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/electron
@clerk/electron-passkeys
@clerk/eslint-plugin
@clerk/expo
@clerk/expo-google-signin
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
API Changes Report
Summary
No API Changes DetectedAll packages have stable APIs with no detected changes. Report generated by Break Check Last ran on |
Internal guards that redirect to a route inside the same component (task
guards, the upcoming account-switcher redirect) push a history entry, so
Back lands on the route that immediately redirects again. `navigate` and
`withRedirect` now accept `{ replace: true }`, threaded through PathRouter
(clerk.navigate already honors it), HashRouter (window.location.replace),
and VirtualRouter (no history, ignored).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
8f65a40 to
23a75d3
Compare
Description
Adds a
replaceoption to the UI router'snavigate/baseNavigateand towithRedirect.Why. The router always pushes a history entry. When a guard redirects to another route in the same component (the sign-in index redirecting to
/sign-in/tasks/…today, or the account switcher redirect in #9651), the route it left stays in history. Pressing Back goes to that route, the guard fires again, and the user is pushed forward again. Back never gets out of the component.With
replace: truethe guard route is dropped from history, so Back goes to the previous page.flowchart LR subgraph push["Before: push"] direction LR R1["/referrer"] --> S1["/sign-in (guard fires)"] S1 -- "push" --> C1["/sign-in/choose"] C1 -. "Back" .-> S1 end subgraph rep["After: replace"] direction LR R2["/referrer"] --> S2["/sign-in (guard fires)"] S2 -- "replace" --> C2["/sign-in/choose"] C2 -. "Back" .-> R2 endPer routing mode
clerk.navigate, which already supportsreplace.window.location.replacefor the fragment.No existing guard changes behavior. The first caller is #9651.
Checklist
pnpm testruns as expected.pnpm buildruns as expected.Type of change
🤖 Generated with Claude Code