Skip to content

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Jan 22, 2026

Summary

  • Renames setActive method to setSelected across the entire monorepo
  • Renames all related types (SetActive, SetActiveParams, SetActiveNavigate, SetActiveHook)
  • Renames internal flags (__internal_setActiveInProgress, __internal_onBeforeSetActive, __internal_onAfterSetActive)
  • Adds codemod support for automatic migration
  • Updates documentation

This is a breaking change for Core 3 that better reflects the method's behavior with pending sessions.

Changes

Method Rename

  • clerk.setActive()clerk.setSelected()
  • Hooks now return setSelected instead of setActive:
    • useSignIn()
    • useSignUp()
    • useSessionList()
    • useOrganizationList()

Type Renames

  • SetActiveSetSelected
  • SetActiveParamsSetSelectedParams
  • SetActiveNavigateSetSelectedNavigate
  • SetActiveHookSetSelectedHook

Internal Flag Renames

  • __internal_setActiveInProgress__internal_setSelectedInProgress
  • __internal_onBeforeSetActive__internal_onBeforeSetSelected
  • __internal_onAfterSetActive__internal_onAfterSetSelected

Packages Updated

  • @clerk/shared
  • @clerk/clerk-js
  • @clerk/react
  • @clerk/nextjs
  • @clerk/vue
  • @clerk/expo
  • @clerk/ui
  • @clerk/testing
  • @clerk/upgrade

Codemod

Extended transform-remove-deprecated-props.cjs to automatically migrate:

  • Method calls: clerk.setActive(...)clerk.setSelected(...)
  • Destructuring: const { setActive } = useSignIn()const { setSelected } = useSignIn()
  • Type references
  • Import specifiers

Test plan

  • Build passes for all 20 packages
  • All existing tests updated to use new names
  • Run full test suite
  • Test codemod on sample user code

Closes USER-4041

Summary by CodeRabbit

  • Breaking Changes

    • Public API renamed: setActive() → setSelected(); callback param beforeEmit → navigate (signature updated). Update integrations.
  • Documentation

    • Migration guidance and upgrade notes added.
  • Chores

    • Codemod provided to automate the rename across codebases.
  • Tests

    • Test suites, fixtures, and examples updated to use the new setSelected naming.

✏️ Tip: You can customize this high-level summary in your review settings.

…e setActive to setSelected

BREAKING CHANGE: The `setActive` method has been renamed to `setSelected` to better reflect its behavior with pending sessions.

## Method Rename
- `clerk.setActive()` → `clerk.setSelected()`
- Hooks now return `setSelected` instead of `setActive`:
  - `useSignIn()`
  - `useSignUp()`
  - `useSessionList()`
  - `useOrganizationList()`

## Type Renames
- `SetActive` → `SetSelected`
- `SetActiveParams` → `SetSelectedParams`
- `SetActiveNavigate` → `SetSelectedNavigate`
- `SetActiveHook` → `SetSelectedHook`

## Internal Flag Renames
- `__internal_setActiveInProgress` → `__internal_setSelectedInProgress`
- `__internal_onBeforeSetActive` → `__internal_onBeforeSetSelected`
- `__internal_onAfterSetActive` → `__internal_onAfterSetSelected`

Includes codemod support for automatic migration.
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2026

🦋 Changeset detected

Latest commit: 1c39685

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

This PR includes changesets to release 21 packages
Name Type
@clerk/clerk-js Major
@clerk/shared Major
@clerk/react Major
@clerk/nextjs Major
@clerk/vue Major
@clerk/expo Major
@clerk/ui Major
@clerk/testing Major
@clerk/upgrade Patch
@clerk/chrome-extension Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/backend Patch
@clerk/expo-passkeys Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/localizations Patch
@clerk/msw Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/tanstack-react-start 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

@vercel
Copy link

vercel bot commented Jan 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Jan 22, 2026 4:49pm

Request Review

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 22, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7645

@clerk/upgrade

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

@clerk/vue

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

commit: 1c39685

@jacekradko jacekradko changed the title feat(core-3): Rename setActive to setSelected feat(*): Rename setActive to setSelected Jan 22, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 22, 2026

📝 Walkthrough

Walkthrough

Renames public API and related types/identifiers from "Active" to "Selected": setActivesetSelected, SetActive*SetSelected*, __internal_setActiveInProgress__internal_setSelectedInProgress, and window hooks __internal_onBeforeSetActive/__internal_onAfterSetActive__internal_onBeforeSetSelected/__internal_onAfterSetSelected. Changes touch core clerk-js, shared types, React/Vue/Expo hooks, Next.js providers, UI components, tests, docs, a changeset, and an upgrade codemod that automates the rename. No runtime behavior changes beyond identifier/type renames and updated signatures.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 31.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(*): Rename setActive to setSelected' clearly and concisely describes the main change - renaming an API method across the codebase.
Linked Issues check ✅ Passed The PR comprehensively addresses USER-4041 by renaming setActive to setSelected across all packages, types, hooks, internal flags, and includes a codemod for migration.
Out of Scope Changes check ✅ Passed All changes are directly related to the renaming objective. No out-of-scope modifications were introduced; the scope remains focused on the setActive → setSelected migration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/clerk-js/src/core/__tests__/clerk.test.ts (1)

2353-2406: Rename window hook stubs to __internal_onBefore/AfterSetSelected.

The test still stubs __internal_onBeforeSetActive / __internal_onAfterSetActive, but core now invokes the *Selected hooks. This can make the updateClient assertion fail and leaves the new hooks uncleared between tests. Please rename these stubs and cleanups (and apply the same rename across this file).

🛠️ Proposed fix (apply similarly to other occurrences in this file)
- (window as any).__internal_onBeforeSetActive = mockOnBeforeSetActive;
- (window as any).__internal_onAfterSetActive = mockOnAfterSetActive;
+ (window as any).__internal_onBeforeSetSelected = mockOnBeforeSetActive;
+ (window as any).__internal_onAfterSetSelected = mockOnAfterSetActive;

- (window as any).__internal_onBeforeSetActive = null;
- (window as any).__internal_onAfterSetActive = null;
+ (window as any).__internal_onBeforeSetSelected = null;
+ (window as any).__internal_onAfterSetSelected = null;

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@packages/upgrade/src/codemods/transform-remove-deprecated-props.cjs`:
- Around line 456-473: The current unconditional rename of Identifier
'setActive' to 'setSelected' is too broad; restrict it to only bindings created
by Clerk hooks/instances by checking the identifier's binding origin before
renaming. In the root.find(j.Identifier, { name: 'setActive' }) loop, skip
identifiers unless their binding (via path.scope.getBinding(path.node.name))
exists and its declaration/init is a Clerk hook call or Clerk instance (e.g.,
VariableDeclarator where init is a CallExpression that satisfies an
isClerkHookCall helper or an Object/MemberExpression originating from a 'clerk'
object); only then change path.node.name to 'setSelected' and mark
changed/stats. Add or use an isClerkHookCall utility to encapsulate hook
detection so unrelated patterns like useState destructuring are not renamed.

Comment on lines +456 to +473
// Rename setActive identifier (e.g., standalone call or destructured)
root.find(j.Identifier, { name: 'setActive' }).forEach(path => {
// Skip if it's part of a member expression property (already handled above)
if (
path.parent &&
(path.parent.node.type === 'MemberExpression' || path.parent.node.type === 'OptionalMemberExpression') &&
path.parent.node.property === path.node
) {
return;
}
// Skip if it's part of an import specifier (handled separately)
if (path.parent && path.parent.node.type === 'ImportSpecifier') {
return;
}
path.node.name = 'setSelected';
changed = true;
stats('setActiveRenamed');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Scope the setActive identifier rename to Clerk bindings only.

The current Identifier-wide rename will also rewrite unrelated identifiers (e.g., const [x, setActive] = useState(...)), which is a breaking codemod bug. Please restrict renames to bindings that originate from Clerk hooks or Clerk instances.

🐛 Proposed fix (scope rename to Clerk hook destructuring)
-  // Rename setActive identifier (e.g., standalone call or destructured)
-  root.find(j.Identifier, { name: 'setActive' }).forEach(path => {
-    // Skip if it's part of a member expression property (already handled above)
-    if (
-      path.parent &&
-      (path.parent.node.type === 'MemberExpression' || path.parent.node.type === 'OptionalMemberExpression') &&
-      path.parent.node.property === path.node
-    ) {
-      return;
-    }
-    // Skip if it's part of an import specifier (handled separately)
-    if (path.parent && path.parent.node.type === 'ImportSpecifier') {
-      return;
-    }
-    path.node.name = 'setSelected';
-    changed = true;
-    stats('setActiveRenamed');
-  });
+  // Rename bindings originating from Clerk hook destructuring only
+  root
+    .find(j.VariableDeclarator, { id: { type: 'ObjectPattern' } })
+    .filter(path => isClerkHookCall(path.node.init))
+    .forEach(path => {
+      const hasSetActive = path.node.id.properties?.some(
+        prop => prop.type === 'ObjectProperty' && isPropertyKeyNamed(prop.key, 'setActive'),
+      );
+      if (hasSetActive) {
+        path.scope.rename('setActive', 'setSelected');
+        changed = true;
+        stats('setActiveRenamed');
+      }
+    });

If you want, I can draft isClerkHookCall and tests for common cases.

🤖 Prompt for AI Agents
In `@packages/upgrade/src/codemods/transform-remove-deprecated-props.cjs` around
lines 456 - 473, The current unconditional rename of Identifier 'setActive' to
'setSelected' is too broad; restrict it to only bindings created by Clerk
hooks/instances by checking the identifier's binding origin before renaming. In
the root.find(j.Identifier, { name: 'setActive' }) loop, skip identifiers unless
their binding (via path.scope.getBinding(path.node.name)) exists and its
declaration/init is a Clerk hook call or Clerk instance (e.g.,
VariableDeclarator where init is a CallExpression that satisfies an
isClerkHookCall helper or an Object/MemberExpression originating from a 'clerk'
object); only then change path.node.name to 'setSelected' and mark
changed/stats. Add or use an isClerkHookCall utility to encapsulate hook
detection so unrelated patterns like useState destructuring are not renamed.

@jacekradko
Copy link
Member Author

Superseded by #7646 which takes a different approach - splitting setActive into purpose-specific methods (selectSession and selectOrganization) rather than a simple rename.

@jacekradko jacekradko closed this Jan 22, 2026
@jacekradko jacekradko deleted the jacek/user-4041-rename-setactive-to-setselected branch January 22, 2026 16:53
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.

2 participants