Skip to content

🐞[Bug]: Build-time SSG crash across 29 routes caused by Clerk SignInButton without ClerkProvider #2522

Closed

Description

@bobby404-K

Describe the bug

When running a production build (npm run build) in standard environments without VITE_CLERK_PUBLISHABLE_KEY, static site generation (SSG) crashes across 29 routes, failing the entire production build with exit code 1:

[ERROR] Error: Unable to build website for locale en.
[cause]: Error: Docusaurus static site generation failed for 31 paths:
  - "/updates/"
  - "/learn/"
  - "/learn/github-for-beginners"
  - "/learn/github-for-beginners/achievements"
  - "/learn/github-for-beginners/codespaces"
  ... (27 additional /learn/* subpages)
[cause]: Error: @clerk/react: SignInButton can only be used within the <ClerkProvider /> component. Learn more: https://clerk.com/docs/components/clerk-provider
    at Object.throwMissingClerkProviderError (server.bundle.js:71077:10)
    at server.bundle.js:70640:16
    at useAssertWrappedByClerkProvider (server.bundle.js:74150:4)

Root Cause:

In src/theme/Root.tsx, when clerkPublishableKey is empty or omitted at build time, Root intentionally renders children directly without wrapping them in <ClerkProvider>:

if (!clerkPublishableKey) {
  return content;
}
return <ClerkProvider ...>{content}</ClerkProvider>;

However, both /updates/ and the /learn/* docs section render <DashboardSidebar>. Inside src/components/dashboard/Sidebar/DashboardSidebar.tsx, hook calls (useUser, useClerk) were placed in a try / catch, but in the JSX at lines 198–210, <SignInButton mode="modal"> is rendered unconditionally:

<SignInButton mode="modal">
  <button type="button" className="dashboard-rail-signin" aria-label="Sign in with GitHub">
    <GithubMark />
    {!collapsed && <span>Sign in with GitHub</span>}
  </button>
</SignInButton>

Because <SignInButton> is a component imported from @clerk/react, rendering it without an active <ClerkProvider> context throws Error: @clerk/react: SignInButton can only be used within the <ClerkProvider /> component during static HTML generation. This aborts SSG for every page hosting the sidebar and terminates the build.

The same unhandled <SignInButton> rendering exists in src/components/dashboard/overview/SignedOutHero.tsx and src/components/dashboard/LeaderBoard/Rail.tsx.

Expected behavior

DashboardSidebar.tsx, SignedOutHero.tsx, and Rail.tsx should verify whether Clerk authentication is configured and available (e.g. checking siteConfig.customFields?.clerkPublishableKey). When Clerk is not enabled or during static site generation without ClerkProvider, they should render a standard sign-in button rather than invoking @clerk/react's <SignInButton> component.

Measured Before vs. After:

  • Before: npm run build exits with code 1; static site generation fails for 29+ routes.
  • After: npm run build exits with code 0; all pages generate static HTML successfully.

Activity

  1. github-actions commented on Nov 15, 2026

    @github-actions

    Thanks for opening this issue! 🎉 We'll look into it as soon as possible, estimated time for response is 5–8 hrs.

    Don't raise PR unless assigned to you.

    In the meantime, please provide all necessary details and context to your issue — screenshots or videos of your changes help speed up the review and assignment. If you have questions, reach out to LinkedIn. Your contributions are highly appreciated!😊

    Note: I maintain the repo issue every day twice at 8:00 AM IST and 9:00 PM IST. If your issue goes stale for more than one day, you can tag and comment on this same issue by tagging @sanjay-kv.

    We are here to help you on this journey of open source. Consistent contributions are eligible for sponsorship 💰

    🎁 check our list of amazing people we sponsored so far: GitHub Sponsorship. ✨

    📚Resources which can help you know more about Github 👇🏻

    1. End to End GitHub Beginner Playlist: GitHub Playlist.

    2. Build your GitHub Profile: GitHub Profile Optimisation.

    3. GitHub Handbook for dummies: GitHub Blog for Beginners.

  2. github-actions commented on Nov 15, 2026

    @github-actions

    Thanks for opening this issue. To help maintainers review it faster, please add the missing details below:

    • Fill in the "Describe the bug" section.
    • Fill in the "Expected behavior" section.
  3. bobby404-K commented on Nov 15, 2026

    @bobby404-K
    MemberAuthor

    assign me @sanjay-kv

  4. github-actions commented on Nov 15, 2026

    @github-actions

    ✅ This issue has been closed. Thank you for your contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    level 110 pointsrecodethis is label for leaderboard

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions