You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ports the @clerk/react fix from #8556 to @clerk/astro. Astro carries its own duplicate copy of assertSingleChild (marked // TODO-SHARED) that was not updated when the React-side fix landed.
Same root cause as #8556: when a custom button child crosses a Next-style server/client boundary, React can deliver it as a one-item array. React.Children.only() rejects that shape, which the SDK catches and surfaces as a misleading "multiple children" error to the user. The fix falls back to React.Children.toArray() and accepts a length-1 array of a valid element, preserving the genuine multi-child error path.
This benefits all seven astro unstyled buttons via the shared util: SignInButton, SignUpButton, SignOutButton, SignInWithMetamaskButton, CheckoutButton, SubscriptionDetailsButton, PlanDetailsButton.
Also adds the first React component tests to the astro package, mirroring the regression test from #8556 plus baseline coverage (default child, custom child, array-wrapped single child).
Checklist
pnpm test runs as expected. (21/21 in @clerk/astro, including 3 new tests.)
pnpm build runs as expected. (Full repo build not verified end-to-end — pre-existing failures in unrelated workspace packages, unrelated to this change.)
(If applicable) JSDoc comments have been added or updated for any package exports — N/A, no public API surface change.
Port the @clerk/react fix from #8556 to @clerk/astro so the same
RSC server/client boundary case (custom child arriving as a one-item
array) no longer trips the misleading "multiple children" error.
Adds the first React component tests to the astro package covering
the default child, a normal single custom child, and the array-
wrapped single child regression case.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This PR fixes the Astro package's unstyled button components to accept a single React element passed as a one-item array. The assertSingleChild utility in utils.tsx now catches the error from React.Children.only() and checks if the converted array contains exactly one valid React element, returning it instead of treating it as a multiple-children error. A new test suite for SignInButton verifies the default button behavior, custom button children with their own click handlers, and the new one-item array scenario. A changeset entry documents this patch release.
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
clerk/javascript#8556: Both PRs update the same assertSingleChild logic for unstyled button children to accept a one-item array as a valid single React element (and add corresponding SignInButton regression tests).
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Linked Issues check
⚠️ Warning
The linked issue #39 concerns fixing Content-Type and User-Agent in @clerk/edge, which is completely unrelated to this PR about fixing array-wrapped children in @clerk/astro buttons.
The PR appears to address #8556 and other references, but the linked issue #39 is unrelated to these changes. Verify the correct linked issue is attached or remove the incorrect link.
✅ Passed checks (4 passed)
Check name
Status
Explanation
Title check
✅ Passed
The title 'fix(astro): accept single array child in unstyled buttons' clearly and specifically describes the main change: fixing unstyled Astro buttons to accept a single element passed as an array.
Description check
✅ Passed
The description provides detailed context about porting the React fix to Astro, explains the root cause and solution, lists affected components, and documents test coverage additions.
Out of Scope Changes check
✅ Passed
All changes align with the stated objective of porting the @clerk/react fix to @clerk/astro: updating assertSingleChild utility, adding regression tests, and adding baseline test coverage for unstyled buttons.
Docstring Coverage
✅ Passed
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
Tip
💬 Introducing Slack Agent: The best way for teams to turn conversations into code.
Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Generate code and open pull requests
Plan features and break down work
Investigate incidents and troubleshoot customer tickets together
Automate recurring tasks and respond to alerts with triggers
Summarize progress and report instantly
Built for teams:
Shared memory across your entire org—no repeating context
Per-thread sandboxes to safely plan and execute work
Governance built-in—scoped access, auditability, and budget controls
One agent for your entire SDLC. Right inside Slack.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Ports the
@clerk/reactfix from #8556 to@clerk/astro. Astro carries its own duplicate copy ofassertSingleChild(marked// TODO-SHARED) that was not updated when the React-side fix landed.Same root cause as #8556: when a custom button child crosses a Next-style server/client boundary, React can deliver it as a one-item array.
React.Children.only()rejects that shape, which the SDK catches and surfaces as a misleading "multiple children" error to the user. The fix falls back toReact.Children.toArray()and accepts a length-1 array of a valid element, preserving the genuine multi-child error path.This benefits all seven astro unstyled buttons via the shared util:
SignInButton,SignUpButton,SignOutButton,SignInWithMetamaskButton,CheckoutButton,SubscriptionDetailsButton,PlanDetailsButton.Also adds the first React component tests to the astro package, mirroring the regression test from #8556 plus baseline coverage (default child, custom child, array-wrapped single child).
Checklist
pnpm testruns as expected. (21/21 in@clerk/astro, including 3 new tests.)pnpm buildruns as expected. (Full repo build not verified end-to-end — pre-existing failures in unrelated workspace packages, unrelated to this change.)clerk-docsPR Add example for multiple children on <SignUpButton>/<SignInButton> components clerk-docs#3358 already covers the multi-child guidance.Type of change
References
@clerk/reactfix this ports