S
SolidJS2mo ago
ColbyD

Express, SolidJS, and Solid Router- SSR Troubles

Good afternoon! I am scaffolding a new project that will use SolidJS for the front end, Solid Router as a router, express as my backend. I want to isomorphically render this app taking advantage of all the benefits of SSR. I am using webpack as my bundler, and have achieved server rendering and client side hydration. However, when trying to implement Solid Router, I am plagued by an error of attempting to use Client Side features on the server. I have tried soooo much to find a workaround, even investigating using TanStack router, but I would really like to just use SolidRouter as it is simpler and the native router for Solid. I will share a link to the github repo for my project so far, and if anyone has any advice as to how to set up routing that works with SSR, I would be more then happy to hear your thoughts. Thank you! https://github.com/colbydeniston/yart.git https://github.com/colbydeniston/yart
GitHub
GitHub - colbydeniston/yart
Contribute to colbydeniston/yart development by creating an account on GitHub.
GitHub
GitHub - colbydeniston/yart
Contribute to colbydeniston/yart development by creating an account on GitHub.
4 Replies
mdynnl
mdynnl2mo ago
https://github.com/ryansolid/solid-ssr-workbench This uses the old router API but still should serve the purpose. looks like @solidjs/router browser build is being resolved when running with node, webpack chooses not to bundle for target node and hence trying to resolve at runtime which @solidjs/router doesn't ship. i think we need to specifically write a webpack plugin to have it bundle solid packages that has solid condition. or use rollup
ColbyD
ColbyDOP2mo ago
oh interesting.. thank you for sharing, i did not know that repo existed. I will take a look and see if I can implement in my own setup.
mdynnl
mdynnl2mo ago
your current webpack looks fine on the surface, it's essentially the same with rollup setup but the issue was this hence the suggestion to use rollup like if you have solid router directly in your source folder, webpack would bundle it and things should work
ColbyD
ColbyDOP2mo ago
okay for sure. I will poke around here tomorrow, put in a full day today brains fried lol, after the fourth. Thanks again

Did you find this page helpful?