-
Notifications
You must be signed in to change notification settings - Fork 476
feat(nextjs): export Mosaic UserButton from an experimental subpath #9338
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
Changes from all commits
9aae101
bcdb6a6
05d2c8f
c5c232d
193044f
8040174
6fa601a
c9672a9
b67e079
6a40d98
f0a2895
a9d0f11
48d3ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| --- | ||
| '@clerk/nextjs': minor | ||
| '@clerk/react': minor | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Add an experimental subpath for Mosaic components that mount directly in your app's tree rather than being rendered by clerk-js. `UserButton` is the first one. It reads Clerk through hooks, so a `ClerkProvider` above it is all it needs: | ||
|
|
||
| ```tsx | ||
| import { UserButton } from '@clerk/nextjs/experimental/mosaic'; | ||
| ``` | ||
|
|
||
| Pair it with the stylesheet, which carries the design tokens and every component rule: | ||
|
|
||
| ```css | ||
| @import '@clerk/nextjs/experimental/mosaic/styles.css' layer(clerk); | ||
| ``` | ||
|
|
||
| The surface and the components behind it will change without a major version while they are experimental. | ||
|
|
||
| In `@clerk/ui`, the Mosaic stylesheet moves from `@clerk/ui/styles.css` to `@clerk/ui/experimental/mosaic/styles.css` to sit alongside the components it styles. Update the import if you were using it. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 'use client'; | ||
|
|
||
| /** | ||
| * Mosaic components mounted directly in the host app's tree, rather than through clerk-js. They | ||
| * read Clerk via hooks, so a `ClerkProvider` above them is all they need. | ||
| * | ||
| * Pair with the stylesheet, which carries the design tokens and every component rule: | ||
| * | ||
| * ```css | ||
| * @import '@clerk/nextjs/experimental/mosaic/styles.css' layer(clerk); | ||
| * ``` | ||
| * | ||
| * @experimental The surface and the components behind it are subject to change. | ||
| */ | ||
| export { UserButton } from '@clerk/react/experimental/mosaic'; | ||
| export type { UserButtonProps } from '@clerk/react/experimental/mosaic'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| 'use client'; | ||
|
|
||
| /** | ||
| * Mosaic components mounted directly in the host app's tree, rather than through clerk-js. They | ||
| * read Clerk via `@clerk/shared/react` hooks, so a `ClerkProvider` above them is all they need. | ||
| * | ||
| * Pair with the stylesheet, which carries the design tokens and every component rule: | ||
| * | ||
| * ```css | ||
| * @import '@clerk/react/experimental/mosaic/styles.css' layer(clerk); | ||
| * ``` | ||
| * | ||
| * @experimental The surface and the components behind it are subject to change. | ||
| */ | ||
| export { UserButton } from '@clerk/ui/experimental/mosaic'; | ||
| export type { UserButtonProps } from '@clerk/ui/experimental/mosaic'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| /** | ||
| * The `build:mosaic` entry is published as `@clerk/ui/experimental/mosaic` and mounted directly in | ||
| * host apps, so it must stay Emotion-free: pulling `@emotion/react` in ships a second styling | ||
| * runtime to every consumer. Nothing about the barrel enforces that — one legacy component reached | ||
| * from the graph (an `sx` prop, a `Box`, a `keyframes`) drags it back in silently. This fails the | ||
| * build instead. | ||
| */ | ||
|
|
||
| import { readFileSync } from 'node:fs'; | ||
|
|
||
| const BUNDLE = new URL('../dist-mosaic/index.js', import.meta.url); | ||
|
|
||
| const source = readFileSync(BUNDLE, 'utf8'); | ||
| const offenders = source.split('\n').filter(line => line.includes('@emotion')); | ||
|
|
||
| if (offenders.length > 0) { | ||
| console.error(`Found Emotion in the Mosaic build output (dist-mosaic/index.js):\n${offenders.join('\n')}`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('✅ No Emotion found in the Mosaic build output'); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Public entry for `@clerk/ui/experimental/mosaic`. The side-effect import keeps every migrated | ||
| // component in the StyleX graph so the emitted `styles.css` stays complete, without making them API: | ||
| // `./styles` is the build barrel, and re-exporting it would publish the headless primitive types too. | ||
| import './styles'; | ||
|
|
||
| export { UserButton } from './user-button/user-button'; | ||
| export type { UserButtonProps } from './user-button/user-button'; | ||
|
Comment on lines
+6
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win Document Line 7 makes As per coding guidelines, “All public APIs must be documented with JSDoc.” 🤖 Prompt for AI AgentsSource: Coding guidelines |
||
Uh oh!
There was an error while loading. Please reload this page.