-
Notifications
You must be signed in to change notification settings - Fork 436
feat(clerk-js,react): Add js prop for bundled clerk-js support #7779
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
base: main
Are you sure you want to change the base?
Conversation
Adds `ui` prop to ClerkProvider for specifying UI metadata.
Each SDK decides whether to use `ui.ctor` based on support level.
- `@clerk/ui` exports only `{ ui }` with version and ctor
- Chrome extension uses `ui.ctor` (verified to work)
- React, Vue, Astro use CDN loading (not verified for bundling yet)
- Omit `clerkUiCtor` from public ClerkProviderProps type
…dledUI escape hatch
- Remove top-level ClerkUI from ClerkOptions, now only available via ui.ClerkUI
- SDKs construct ui: { version?, url?, ClerkUI } when loading from CDN
- Fix TypeScript declaration file issues by not spreading branded Ui type
- Update warning function to check ui.version for version pinning detection
The rename commit missed the actual runtime export in packages/ui/src/index.ts.
This fixes the bundled UI scenario where clerk.load({ ui }) expects ui.ClerkUI.
Add tests covering the ClerkUIPromise path in plugin initialization: - Version pinning only (ui.version) - Custom URL only (ui.url) - Both version and URL combined - ClerkUIPromise resolves to window.__internal_ClerkUICtor
Check for options.ui.ClerkUI before loading from CDN. If a bundled ClerkUIConstructor is provided, return it directly instead of calling loadClerkUiScript.
Use null-coalescing to fall back to options.clerkUiUrl when options.ui?.url is not provided, preventing custom/self-hosted UI URLs from being overwritten with undefined. Also adds vitest setup and tests for the clerkUiUrl fallback behavior.
…opt-out for Next.js Replaces __internal_forceBundledUI with __internal_preferCDN to fix double-loading issue where importing @clerk/ui would bundle ClerkUI but still load it from CDN. - Default behavior now uses bundled UI when ui.ClerkUI is provided - Next.js sets __internal_preferCDN due to bundling issues - Chrome Extension simplified (no longer needs explicit flag)
Resolve conflicts by taking main's approach: - Use `clerkUICtor` prop instead of `ui` prop - Use `prefetchUI` option for controlling UI prefetching - Remove `clerkJSVariant` option - Update function naming to use uppercase (e.g., loadClerkJSScript)
Add a `js` prop to ClerkProvider (React, Next.js, Vue, Astro) that allows bundling @clerk/clerk-js with the application instead of loading from CDN, mirroring the established `ui` prop pattern from @clerk/ui. - Add branded Js type and bundled/server/entry exports to @clerk/clerk-js - Add js prop to ClerkOptions in @clerk/shared - Support bundled js.ClerkJS in isomorphicClerk with CDN skip - Add Next.js RSC resolution with cached promise pattern - Add Vue plugin support for bundled ClerkJS constructor - Add Astro integration support with PUBLIC_CLERK_SKIP_JS_CDN env var - Add export snapshot tests for @clerk/clerk-js
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@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: |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughAdds a new package Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/astro/src/server/build-clerk-hotload-script.ts (1)
6-83:⚠️ Potential issue | 🟠 MajorAdd explicit return type and JSDoc for the exported function.
This exported API lacks the required explicit return type and comprehensive JSDoc. Please add them to satisfy the TypeScript and public API documentation guidelines.
✅ Suggested fix
+/** + * Builds the Clerk hotload markup (script and/or preload link). + * + * `@param` locals - Astro API context locals. + * `@returns` HTML string containing the required tags. + * `@example` + * const html = buildClerkHotloadScript(ctx.locals); + */ -function buildClerkHotloadScript(locals: APIContext['locals']) { +function buildClerkHotloadScript(locals: APIContext['locals']): string {
🧹 Nitpick comments (1)
packages/clerk-js/src/server.ts (1)
12-21: JSDoc example may be misleading for server export.The example shows importing from
@clerk/clerk-js/bundled, but this file isserver.tswhich is resolved via conditional exports forreact-server. Users importing directly won't use this path explicitly. Consider updating the example to clarify the automatic resolution or showing the actual import path that resolves to this module.
Summary
jsprop forClerkProviderthat mirrors theuiprop approachreact-serverconditional exportChanges
@clerk/clerk-js:
./bundledexport with brandedjsobject containing ClerkJS constructor./entryexport for dynamic imports./internalexport for theJstypereact-servercondition exports server-safe marker (no browser code)@clerk/react:
jsprop toClerkProviderPropsisomorphicClerkto handlejsprop loadingUsage
Test plan
pnpm buildpasses for clerk-js and react packagesjsprop is omitted🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Configuration
Tests