solidjs / solid-docs-next

SolidJS Docs.
https://docs.solidjs.com/
208 stars 225 forks source link

[Content]: <Router> - `root` and Suspense are required with file-based routing #795

Open klequis opened 1 week ago

klequis commented 1 week ago

📚 Subject area/topic

SolidStart > Routing

📋 Page(s) affected (or suggested, for new content)

https://docs.solidjs.com/solid-start/building-your-application/routing

📋 Description of content that is out-of-date or incorrect

In a SolidStart project using <FileRoutes>, <Router> requires both

See discussion that starts here: https://discord.com/channels/722131463138705510/861229287868858379/1255593230150402078

If there is agreement that these two points need to be made in the doc, I'll create a PR.

🖥️ Reproduction in StackBlitz (if reporting incorrect content or code samples)

No response

klequis commented 1 week ago

Additional confirmation that Suspense is required

Question Why am I getting a hydration error?

Answer You forgot to wrap your routes with suspense

Why Because inside FileRoutes there's a hidden mechanism of lazy loading your pages. That's why you need a suspense to make it work properly.