ClerkProvider mounts the `@clerk/ui` component renderer on every page load (~234 KB extra JS without any auth intent)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- next.js, node.js, react, typescript
- Lĩnh vực
- authentication, frontend, performance
Hướng nghiên cứu
Start by tracing the provider effects in @clerk/react and how __internal_updateProps and ensureMounted() interact in @clerk/clerk-js; the issue cites their published package files and the related fixes #4498, #4876, and #7901. Reproduce with a Next.js App Router page that has no Clerk components, then inspect the network chunks. Done means the renderer and billing chunks do not load on an idle page while mount*() and open*() still work as expected.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
With a plain <ClerkProvider> (Next.js App Router, UI loaded from the Clerk CDN, no ui prop), every page load
downloads and evaluates the full @clerk/ui renderer after v1/client, even if the page renders no Clerk component
and no modal is ever opened. We expected the renderer to mount on the first open*() / mount*() call.
Measured on a production app (signed out, no Clerk component on the page, transfer sizes):
| Chunk | Transfer |
|---|---|
framework_ui_*_1.25.0.js |
43 KB |
ui-common_ui_*_1.25.0.js |
122 KB |
vendors_ui_*_1.25.0.js |
64 KB |
subscriptionDetails_ui_*_1.25.0.js |
5 KB |
That is ~234 KB on the wire, ~765 KB of raw JS to parse and evaluate on every page view, plus ui.browser.js itself.
subscriptionDetails is loaded although Clerk Billing is not used. With the bundled ui prop the same chunks load,
from the app bundle instead.
Versions
@clerk/nextjs7.5.14,@clerk/react6.12.0,@clerk/shared4.25.0@clerk/clerk-js6.41.0 (CDN,@6),@clerk/ui1.25.0 (CDN, version pinned)- Next.js 16.4.3, React 19.3.0
- Same code paths in the latest versions as of 2026-11-05:
@clerk/react6.18.6,@clerk/clerk-js6.42.3,@clerk/ui1.42.4
Cause (code references in the published packages)
@clerk/react6.12.0,dist/ClerkProvider-GF8qvIpk.mjs:1544–1549:useLoadedIsomorphicClerkhas two effects that
callisomorphicClerk.__internal_updateProps(...), one forappearanceand one forlocalization. They run on the
first mount, even if the values equal the options already passed toclerk.load().@clerk/clerk-js6.41.0 (dist/clerk.browser.js):__internal_updatePropsalways mounts first:
return this.#eR?.then(e=>e.ensureMounted()).then(e=>e.updateProps(t)). This dates from #4498.@clerk/ui1.25.0,dist/Components.js:34–42: the firstensureMounted()importslazyModules/common.js
(framework, ui-common, vendors) and rendersComponents.@clerk/ui1.25.0,dist/Components.js:431–444anddist/lazyModules/drawers.js:Componentsalways renders
MountedCheckoutDrawer,MountedPlanDetailDrawerandMountedSubscriptionDetailDrawer. They areReact.lazy
modules, so rendering them while closed loads the billing chunk.
Expected
__internal_updatePropscalled before the renderer is mounted should store the props and apply them on mount,
instead of callingensureMounted(). A similar early mount was fixed for the keyless prompt in #4876. #7901 already
preloads component chunks onmount*()/open*(), so the first modal would not wait long.- The billing drawers should render only when opened, or only when Billing is enabled for the instance.
Steps to reproduce
- Create a Next.js App Router app and wrap the root layout in
<ClerkProvider>(CDN UI, nouiprop). Pass
localizationorappearance, or none: the effects run on mount either way. - Render a page without any Clerk component and do not interact with it.
- In the Network panel, after
v1/client, theframework_ui_*,ui-common_ui_*,vendors_ui_*and
subscriptionDetails_ui_*chunks load.
Related question: shared React variant
@clerk/react sets clerkUIVariant: "shared" for compatible React versions (ClerkProvider-GF8qvIpk.mjs:1536–1539),
and @clerk/ui ships dist/ui.shared.browser.js without its own React. The CDN loader in @clerk/shared 4.25.0
always requests dist/ui.browser.js (dist/loadClerkJsScript.js:141–149). We found no consumer of clerkUIVariant
in clerk.browser.js 6.41.0 or in ui.browser.js 1.25.0. As a result the CDN path always loads the variant with its
own React (framework_ui, ~43 KB). Is there a supported way to load the shared variant from the CDN, or is this
expected?
Thanks!
- Ngôn ngữ chính
- TypeScript
- Star
- 1.8k
- Fork
- 492
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 374
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của clerk/javascript
-
<SignIn />: the reset password code step renders an empty, focusable back button with no accessible nameCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
clerk/javascript#10708 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Built-in reverification dialog lacks an accessible name (aria-dialog-name)Có thể đã có người làm @ItsShivam05 đã nhận 5 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
clerk/javascript#10548 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
MFA enrollment QR SVG lacks an accessible name (svg-img-alt)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
clerk/javascript#10547 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
<SignIn />: first "Use email" click switches back to phone when `initialValues.phoneNumber` is setCó thể đã có người làm @twicestruck đã nhận 23 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
clerk/javascript#10487 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
useLoadedIsomorphicClerk misses "ready" when a ClerkProvider remounts after clerk-js has loaded — <ClerkLoading> never resolvesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
clerk/javascript#10462 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của clerk/javascript
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
milind-soni/OpenMausBot#6730 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Đang mởarea: @angular/build
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
angular/angular-cli#34764 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status/need-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google-gemini/gemini-cli#30384 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
P2
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:image documentation good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày