Skip to content

Conversation

@bratsos
Copy link
Member

@bratsos bratsos commented Jan 23, 2026

Add runtime version check in ClerkUi constructor to detect incompatible @clerk/clerk-js versions. In development instances, logs a warning; in production, throws ClerkRuntimeError with actionable upgrade guidance.

Also moves shared version utilities to @clerk/shared/utils.

Description

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

    • Added runtime version compatibility validation for Clerk.js during UI initialization; incompatible versions throw in development and warn in production.
    • Added a convenience API to test if a version meets a minimum requirement.
    • Introduced a new minimum-supported Clerk.js version constant.
  • Tests

    • Added comprehensive tests for version checks and UI initialization behaviors (dev vs prod, pre-releases, and edge cases).

@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 38deb49

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

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

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Feb 3, 2026 2:23pm

Request Review

@github-actions github-actions bot added the react label Jan 23, 2026
@bratsos bratsos force-pushed the alexbratsos/user-4102-implement-minimum-clerkjs-sdk-version-in-clerkui branch from f6578d0 to 682ea78 Compare January 23, 2026 20:44
Base automatically changed from brkalow/sacramento to main January 23, 2026 21:05
@bratsos bratsos force-pushed the alexbratsos/user-4102-implement-minimum-clerkjs-sdk-version-in-clerkui branch from 682ea78 to a033dda Compare January 26, 2026 17:07
@bratsos bratsos force-pushed the alexbratsos/user-4102-implement-minimum-clerkjs-sdk-version-in-clerkui branch from a033dda to d1d402b Compare January 26, 2026 17:25
@@ -1,3 +1,5 @@
export const MIN_CLERK_JS_VERSION = '5.112.0';
Copy link
Member

Choose a reason for hiding this comment

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

Is 5.112.0 the correct version here or should this be pinned to 6.0.0 since thats the major for core 3? The tests seem to use 6.0.0 as the expected minimum which made me wonder if this was intentional or if the constant just needs updating.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think the version when we added ModuleManager/ClerkUi was 5.112.0 so in theory this could be the minimum clerk js version. But we can also arbitrarily set this to 6.0.0 to make it available only on Core3. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated this to 6.0.0 73ebcb5

logger.warnOnce(incompatibilityMessage);
} else {
throw new ClerkRuntimeError(incompatibilityMessage, { code: 'clerk_ui_version_mismatch' });
}
Copy link
Member

Choose a reason for hiding this comment

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

Should this be the other way around? Typically we want to fail fast in development (so devs catch issues early) but be more lenient in production (to avoid breaking user-facing apps). The current behavior warns in dev (easy to miss) but throws in prod (could cause outages).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah that makes more sense. I went with "You don't want a mismatch on production" as you may end up with weird-looking UI, but I agree. 4e1751d

`@clerk/ui@${ClerkUi.version} requires @clerk/clerk-js@>=${MIN_CLERK_JS_VERSION}, ` +
`but found an incompatible version${clerkVersion ? ` (${clerkVersion})` : ''}. ` +
`Please upgrade @clerk/clerk-js (or your framework SDK) to a compatible version.`;
}
Copy link
Member

Choose a reason for hiding this comment

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

Looking at clerk-js, it always instantiates ClerkUi with new ModuleManager(), and clerkVersion comes from the Clerk instance which should always have its version set. Is there a scenario where ClerkUi would be instantiated without a moduleManager or without knowing the clerkVersion? If this is just defensive coding thats fine, but if theres an actual use case Im curious what it is :)

Copy link
Member Author

Choose a reason for hiding this comment

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

It's just defensive to future-proof us from a mistake. I thought about all different scenarios with pinned/hotloaded clerk-js and before/after we introduced moduleManager/ClerkUi and I don't think you land in this case right now, but you never know in the future.

@nikosdouvlis
Copy link
Member

nikosdouvlis commented Jan 27, 2026

this PR adds a new feature to @clerk/ui and @clerk/shared but I dont see a changeset for it. Should we add one describing the new minimum version check behavior?

This is fine

@bratsos bratsos marked this pull request as ready for review January 30, 2026 16:35
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

This pull request adds runtime Clerk.js SDK version validation to ClerkUi: a new constant MIN_CLERK_JS_VERSION ('6.0.0') and an exported isVersionAtLeast function in versionCheck are introduced. ClerkUi's constructor now parses the detected @clerk/clerk-js version and either throws a ClerkRuntimeError in development or logs a warning in production when the version is incompatible or unparseable. Tests were added for the new checks and version comparisons. A minor import reordering was made in packages/react/build-utils/parseVersionRange.ts. A changeset documents package version bumps.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Linked Issues check ❓ Inconclusive The linked issue (USER-4102) title indicates the feature scope but lacks specific technical requirements to fully validate implementation completeness. Review the linked issue details to confirm whether all specified coding requirements have been implemented in this changeset.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title 'feat(ui): enforce minimum clerk-js version compatibility' clearly and concisely describes the main objective of adding version compatibility checks.
Out of Scope Changes check ✅ Passed All changes align with the core objective: version checking utilities, isVersionAtLeast function, MIN_CLERK_JS_VERSION constant, runtime checks in ClerkUi, and comprehensive tests are all directly related to enforcing minimum clerk-js version compatibility.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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.

@bratsos bratsos requested a review from nikosdouvlis January 30, 2026 17:15
Add runtime version check in ClerkUi constructor to detect incompatible
@clerk/clerk-js versions. In development instances, logs a warning; in
production, throws ClerkRuntimeError with actionable upgrade guidance.
@bratsos bratsos force-pushed the alexbratsos/user-4102-implement-minimum-clerkjs-sdk-version-in-clerkui branch from 4e1751d to 73ebcb5 Compare February 2, 2026 20:47
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 2, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: 38deb49

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.

4 participants