Router Error when on a server with lazy loaded component on root page
When I deploy my website on a webserver and I load the "/" route I get an error in the browser console saying: "Make sure your app is wrapped in a <Router />". I get this message again when I try to navigate to another route.
But I only get the error when loading the root page first. When loading a different route first and navigating to the root page everything works.
Also I only get the error on my server not when testing locally and I can put in a Component from a different Page and it still doesn't work.
My work around is not lazy loading the Component for the root page which works but increases the size of the index.js on every page.
9 Replies
just to be sure, the App is wrapped with Router right? if so, maybe make a minimal repro so the problem can be investigated further
so, you're lazy loading the root component. Suspense might solve it
I've tried using Suspense but the problem still exists and I can reproduce it in a new project.
I've setup an repo with the basic setup: https://github.com/oxydemeton/solid_error
404, forgot to make it public?
Sorry, should bei fixed
really sorry for late reply, https://solid-error-mdynnl.vercel.app/ i did a pnpm install as the lock wasn't up to date other than that same code and no error
probably the issue is what was left out of the repro. do you have a live site for further debugging?
Yes: solid.mabla.name
Even though now it seems like the problem occurs on the /second route
it'd help if you deployed without minification in the meantime i'll try with the minified deployment
![](https://cdn.answeroverflow.com/1127328264562692106/Screenshot_2023-07-09_at_02.28.28.png)
seems to be https://www.modpagespeed.com/ is breaking the module imports
the way it works basically breaks modules