solid-start: [Bug?]: Error: Client-only API called on the server side. When using npm run dev on a brand new solidstart project
Duplicates
- I have searched the existing issues
Latest version
- I have tested the latest version
Current behavior 😯
On running npm run dev for new solid start project (using basic template) throws a bunch of errors about trying to use client side only features on server side. Old projects run fine.
Expected behavior 🤔
SolidStart project should start on local host 3000.
Steps to reproduce 🕹
Steps:
- npm init solid@latest
- Project Name: datePicker
- Is this a SolidStart project? Yes
- Which template would you like to use? basic
- Use Typescript? No
- Project successfully created!
- cd datePicker
- npm install
- npm run dev
-
dev
vinxi dev
vinxi v0.4.3 vinxi starting dev server
WARN No valid compatibility date is specified. nitro 9:59:42 PM
ℹ Using 2024-04-03 as fallback. nitro 9:59:42 PM Please specify compatibility date to avoid unwanted behavior changes: - Add compatibilityDate: ‘2024-11-26’ to the config file. - Or set COMPATIBILITY_DATE=2024-11-26 environment variable.
➜ Local: http://localhost:3000/ ➜ Network: use --host to expose 11. ctrl+click on http://localhost:3000/ 12. command line updates to:
dev vinxi dev
vinxi v0.4.3 vinxi starting dev server
WARN No valid compatibility date is specified. nitro 9:59:42 PM
ℹ Using 2024-04-03 as fallback. nitro 9:59:42 PM Please specify compatibility date to avoid unwanted behavior changes: - Add compatibilityDate: ‘2024-11-26’ to the config file. - Or set COMPATIBILITY_DATE=2024-11-26 environment variable.
➜ Local: http://localhost:3000/ ➜ Network: use --host to expose
9:59:52 PM [vite] page reload vinxi/routes 9:59:52 PM [vite] page reload vinxi/routes (x2) 9:59:52 PM [vite] page reload vinxi/routes (x3) 9:59:54 PM [vite] Error when evaluating SSR module /node_modules/@solidjs/router/dist/index.js: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
9:59:54 PM [vite] Error when evaluating SSR module /src/app.jsx: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
9:59:54 PM [vite] Error when evaluating SSR module /node_modules/@solidjs/start/dist/server/StartServer.jsx: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
9:59:54 PM [vite] Error when evaluating SSR module /node_modules/@solidjs/start/dist/server/index.jsx: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
9:59:54 PM [vite] Error when evaluating SSR module /src/entry-server.jsx: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
9:59:54 PM [vite] Error when evaluating SSR module $vinxi/handler/ssr: |- Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
[h3] [unhandled] H3Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5) { cause: Error: Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>. at Module.notSup (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/solid-js/web/dist/server.js:1136:9) at eval (/mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/@solidjs/router/dist/index.js:1470:49) at async instantiateModule (file:///mnt/c/Users/almos/Documents/Codes/web_dev/datePicker/node_modules/vinxi/node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5), statusCode: 500, fatal: false, unhandled: true, statusMessage: undefined, data: undefined }
Context 🔦
run new SolidStart project in dev mode successfully. Old projects run fine.
Your environment 🌎
System:
OS Name: Microsoft Windows 11 Home
OS Version: 10.0.22631 N/A Build 22631
System Type: x64-based PC
Processor(s): 1 Processor(s) Installed.
[01]: Intel64 Family 6 Model 154 Stepping 3 GenuineIntel ~2700 Mhz
Binaries:
Node: v20.13.1
npm: 10.9.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 18
- Comments: 28 (9 by maintainers)
Commits related to this issue
- Update solid in web-next NB: https://github.com/solidjs/solid-start/issues/1679 — committed to LetsChurch/lets.church by knpwrs 2 years ago
- fix(tests|vite): rollback since vite 6 + solid start causes tests to fail You can find the related open issue here: https://github.com/solidjs/solid-start/issues/1679 — committed to Jakob-Strobl/portfolio by Jakob-Strobl 2 years ago
- fix(dev|test): vite-solidjs plugin rollback for tests and vite 6 for dev Actually vite6 isn't the issue it's the plugin v1.11.0 Part 2 of my fix for this related issue: https://github.com/solidjs/sol... — committed to Jakob-Strobl/portfolio by Jakob-Strobl 2 years ago
- fix(tests|vite): rollback since vite 6 + solid start causes tests to fail You can find the related open issue here: https://github.com/solidjs/solid-start/issues/1679 — committed to Jakob-Strobl/portfolio by Jakob-Strobl 2 years ago
- fix(dev|test): vite-solidjs plugin rollback for tests and vite 6 for dev Actually vite6 isn't the issue it's the plugin v1.11.0 Part 2 of my fix for this related issue: https://github.com/solidjs/sol... — committed to Jakob-Strobl/portfolio by Jakob-Strobl 2 years ago
I think is something specifically with
vite@6.0.2I did override with versionvite@6.0.1and it works.I was able to reproduce this by updating to Vite 6 on the main project. So it is some sort of mismatch on versioning I think. I do use pnpm to be fair so I hadn’t noticed it on any of the projects or examples until I made the vite 6 change. We also happen to be working on updating Vinxi and Vite versions so there should be a release soon that has all the matching versions again. I’m not sure how wrong versions are getting included. Something to do with package resolution and locking I guess but I’m gathering it has to do with sub dependencies depending on different versions of packages.
Same issue on every
pnpm create solid@latestexample I’ve used. I did investigate further using hackernews example using a 3 weeks old sandbox hackernews example in my local env I’ve done the following steps:At this stage I had the
Client-only API on the server sideerror than I didEverything works with the old libs lock references I did perform a diff between the 2 pnpm-lock.yaml I think some dependencies upgrade created a regression.
I found vite to have a dependency to a new version 6.0.2
I did force to override on the package.json with vite: 5.4.10 and it works.
This is my new package.json
Vinxi 0.5 has had other issues when we tried to update so was waiting on those to come in. I can confirm older versions of Vite and Vinxi work properly.
But given that Vite 6 seems to be leaking into new installs through deps of deps in new installs that puts us in an awkward place.
I’m going to lock on Vite 5 for now I think like suggested above and we will deal with it as fixes come in.
Can confirm you can fix-forward by upgrading vinxi to
^0.5.1. Seems the better option than downgrading vite?Explicitly downloading vite@5 in the packages seem to solve the issue.
Maybe it’s a peer deps issue from vinxi?
Had the same problem using pnpm
This
package.jsonworks for NPM (added “overrides”):Same issue. I’m running npm version
10.9.0and node versionv22.11.0on MacOS.Edit: using
pnpmsolved the issue.I had the same issue as well. Using pnpm create solid@latest, pnpm install, pnpm dev. Didn’t give the same issues.