Skip to content

Prerendered pages crash when a Solid island imports kobalte (Client-only API called on the server side) #17583

Closed

Description

@axuj

Astro Info

Astro                    v7.1.6
Vite                     v8.2.0
Node                     v24.11.1
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/solid-js

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

When a Solid component rendered with client:load imports @kobalte/core (or any Solid package that ships a browser-precompiled artifact via the exports.solid condition), the static build fails during prerendering with:

[ERROR] Caught error rendering /: Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.
    at notSup (node_modules/solid-js/web/dist/server.js:760:9)

astro dev works fine; only astro build (prerender environment) crashes.

Reproduction: https://stackblitz.com/github/axuj/astro-solid-kobalte-repro
The repo defaults to the broken (unpatched) state — npm install && npm run build crashes with the error above.

  • npm run repro:fixed → applies the verified workaround patch, builds → succeeds
  • npm run repro:broken → removes the patch again, builds → crashes

The workaround patch (patches/@astrojs+solid-js+7.0.1.patch, applied by patch-package via the postinstall hook) ports the svelte approach into @astrojs/solid-js's dist/index.js: it crawls Solid packages with vitefu's crawlFrameworkPkgs (matching any package whose exports contains a solid condition) and injects resolve.noExternal for every environment where environmentName !== 'client' — including prerender. The patch requires vitefu to be resolvable, so the repro lists it in package.json; an upstream fix should add vitefu to @astrojs/solid-js's own dependencies (as @astrojs/svelte does).

Root cause: @kobalte/core resolves through its exports.solid condition to a precompiled browser artifact:

"exports": {
  ".": {
    "types": "./dist/index.d.ts",
    "solid": "./dist/index.jsx",
    "default": "./dist/index.js"
  }
}

Its chunks call browser-only Solid APIs (e.g. template()) at module top level. During the static build, the prerender environment does not bundle Solid-ecosystem packages: they are left external and resolved by Node. Node does not know the solid condition and picks the default entry, whose top-level code calls browser-only APIs that are stubbed with notSup in solid-js/web/dist/server.js — hence the crash.

@astrojs/svelte already solved the identical problem by crawling framework packages and injecting resolve.noExternal into non-client build environments (see #16210). @astrojs/solid-js is missing the equivalent logic: it has configEnvironmentPlugin (used for optimizeDeps.include/exclude) but never broadcasts a noExternal list of Solid packages to the prerender environment.

What's the expected result?

astro build succeeds and prerenders the page without executing the island's browser-only module graph.

Link to Minimal Reproducible Example

https://stackblitz.com/github/axuj/astro-solid-kobalte-repro

Participation

  • I am willing to submit a pull request for this issue.

Activity

  1. astrobot-houston commented on Aug 3, 2026

    @astrobot-houston
    Contributor
    • Reproduced: Yes
    • Exploration: Yes — View branch
    • Unit Test: No — configEnvironmentPlugin is internal and the solid integration has no existing test infrastructure; the svelte integration's equivalent fix (PR Fix .svelte files in node_modules with Cloudflare prerenderEnvironment: node #16210) also lacks a unit test for this behavior.
    • Priority: P4: important. This is a build-breaking error for any project using @astrojs/solid-js with Solid ecosystem libraries that ship pre-compiled browser artifacts (e.g. @kobalte/core), which is a common use case. There is a workaround (manual patch-package), but it's non-trivial.

    The @astrojs/solid-js integration does not configure resolve.noExternal for non-client environments (like prerender). Solid ecosystem packages such as @kobalte/core ship pre-compiled browser artifacts via the exports.solid condition, but during prerendering they are left external and resolved by Node using the default condition instead — picking up browser-only code that calls template() and other APIs stubbed with notSup() in solid-js/web/dist/server.js. The @astrojs/svelte integration already solved this identical problem in PR #16210 by crawling framework packages with vitefu and injecting resolve.noExternal; the solid integration was never updated with the equivalent logic.

    I found a potential fix for this issue. The fix adds vitefu as a dependency and uses crawlFrameworkPkgs to discover all packages with solid-js as a peer dependency, then marks them as noExternal for all non-client environments via configEnvironment — matching the established pattern from @astrojs/svelte.

    Try this fix

    You can test this fix right now without waiting for a release:

    npm i https://pkg.pr.new/@astrojs/solid-js@8a486ea
    

    If this fixes your issue, please leave a comment letting us know (e.g. "confirmed, this fixes it"). We'll then open a pull request to get this merged.

    Full Triage Report

    Issue Title

    Prerendered pages crash when a Solid island imports kobalte (Client-only API called on the server side)

    Issue Details

    Author: axuj
    Astro Version: 7.1.6 (reported), reproduced against workspace main
    Node: v24.11.1 (reported)
    Output: static
    Integrations: @astrojs/solid-js

    Description

    When a Solid component rendered with client:load imports @kobalte/core (or any Solid package that ships a browser-precompiled artifact via the exports.solid condition), the static build fails during prerendering with:

    Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.
        at notSup (solid-js/web/dist/server.js:760:9)
    

    astro dev works fine; only astro build (prerender environment) crashes.

    Root Cause

    @kobalte/core resolves through its exports.solid condition to a precompiled browser artifact. Its chunks call browser-only Solid APIs (e.g. template()) at module top level. During the static build, the prerender environment does not bundle Solid-ecosystem packages: they are left external and resolved by Node. Node does not know the solid condition and picks the default entry, whose top-level code calls browser-only APIs that are stubbed with notSup in solid-js/web/dist/server.js — hence the crash.

    Reproduction

    Status: ✅ Successfully Reproduced

    Steps to Reproduce

    1. Create an Astro project with @astrojs/solid-js integration
    2. Create a Solid component that imports from @kobalte/core
    3. Use that component in a page with client:load
    4. Run astro build

    Result

    Build fails with:

    [ERROR] Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.
        at notSup (solid-js/web/dist/server.js:760:9)
        at @kobalte/core/dist/chunk/BK63AFY4.js:19:30
    

    Baseline Verification

    Removing the @kobalte/core import and replacing with a plain Solid component allows the build to succeed, confirming the issue is specifically triggered by the kobalte import during prerendering.

    Diagnosis — Confidence: high

    Affected Files

    1. packages/integrations/solid/src/index.ts — The configEnvironmentPlugin() function only sets optimizeDeps.include/exclude but never sets resolve.noExternal.
    2. packages/integrations/solid/package.json — Missing vitefu dependency.

    Reference Implementation

    @astrojs/svelte solved the identical problem in PR #16210 using crawlFrameworkPkgs from vitefu to discover framework packages and add them to resolve.noExternal for all non-client environments.

    Verification — Verdict: bug (high confidence)

    Fix — ✅ Successful

    What Was Changed

    1. package.json — Added vitefu (^1.1.2) as a dependency.
    2. src/index.ts — Used crawlFrameworkPkgs to discover packages with solid-js as a peer dependency and added them to resolve.noExternal for non-client environments.

    Verification

    • Before fix: astro build crashes with Error: Client-only API called on the server side
    • After fix: astro build succeeds, producing /index.html

    This report was made by an LLM. The analysis may be wrong, and the potential fix might not work, but is intended as a starting point for exploring the issue.

  2. added
    triage: fix pending
    - P4: important
    pkg: solid
    on Aug 3, 2026
  3. axuj commented on Aug 3, 2026

    @axuj
    Author

    confirmed, this fixes it. Verified in two places:

  4. added
    triage: fix verified
    and removed
    triage: fix pending
    on Aug 3, 2026
  5. astrobot-houston commented on Aug 3, 2026

    @astrobot-houston
    Contributor

    The fix has been verified! A pull request has been created: #17584

  6. added a commit that references this issue on Aug 3, 2026
    5462b81
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

    - P4: importantpkg: solidtriage: fix verified

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions