Repository navigation
Description
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 → succeedsnpm 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
astrobot-houston commentedon Aug 3, 2026
configEnvironmentPluginis 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.@astrojs/solid-jswith Solid ecosystem libraries that ship pre-compiled browser artifacts (e.g.@kobalte/core), which is a common use case. There is a workaround (manualpatch-package), but it's non-trivial.The
@astrojs/solid-jsintegration does not configureresolve.noExternalfor non-client environments (likeprerender). Solid ecosystem packages such as@kobalte/coreship pre-compiled browser artifacts via theexports.solidcondition, but during prerendering they are left external and resolved by Node using thedefaultcondition instead — picking up browser-only code that callstemplate()and other APIs stubbed withnotSup()insolid-js/web/dist/server.js. The@astrojs/svelteintegration already solved this identical problem in PR #16210 by crawling framework packages withvitefuand injectingresolve.noExternal; the solid integration was never updated with the equivalent logic.I found a potential fix for this issue. The fix adds
vitefuas a dependency and usescrawlFrameworkPkgsto discover all packages withsolid-jsas a peer dependency, then marks them asnoExternalfor all non-client environments viaconfigEnvironment— matching the established pattern from@astrojs/svelte.Try this fix
You can test this fix right now without waiting for a release:
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
mainNode: v24.11.1 (reported)
Output: static
Integrations: @astrojs/solid-js
Description
When a Solid component rendered with
client:loadimports@kobalte/core(or any Solid package that ships a browser-precompiled artifact via theexports.solidcondition), the static build fails during prerendering with:astro devworks fine; onlyastro build(prerender environment) crashes.Root Cause
@kobalte/coreresolves through itsexports.solidcondition to a precompiled browser artifact. Its chunks call browser-only Solid APIs (e.g.template()) at module top level. During the static build, theprerenderenvironment does not bundle Solid-ecosystem packages: they are left external and resolved by Node. Node does not know thesolidcondition and picks thedefaultentry, whose top-level code calls browser-only APIs that are stubbed withnotSupinsolid-js/web/dist/server.js— hence the crash.Reproduction
Status: ✅ Successfully Reproduced
Steps to Reproduce
@astrojs/solid-jsintegration@kobalte/coreclient:loadastro buildResult
Build fails with:
Baseline Verification
Removing the
@kobalte/coreimport 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
packages/integrations/solid/src/index.ts— TheconfigEnvironmentPlugin()function only setsoptimizeDeps.include/excludebut never setsresolve.noExternal.packages/integrations/solid/package.json— Missingvitefudependency.Reference Implementation
@astrojs/sveltesolved the identical problem in PR #16210 usingcrawlFrameworkPkgsfromvitefuto discover framework packages and add them toresolve.noExternalfor all non-client environments.Verification — Verdict: bug (high confidence)
resolve.noExternalis omitted.noExternallogic — it was simply never considered.Fix — ✅ Successful
What Was Changed
package.json— Addedvitefu(^1.1.2) as a dependency.src/index.ts— UsedcrawlFrameworkPkgsto discover packages withsolid-jsas a peer dependency and added them toresolve.noExternalfor non-client environments.Verification
astro buildcrashes withError: Client-only API called on the server sideastro buildsucceeds, producing/index.htmlThis 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.
axuj commentedon Aug 3, 2026
confirmed, this fixes it. Verified in two places:
astrobot-houston commentedon Aug 3, 2026
The fix has been verified! A pull request has been created: #17584
fix(solid): bundle Solid ecosystem packages in non-client environments (