solidjs / solid-router

A universal router for Solid inspired by Ember and React Router
MIT License
1.13k stars 143 forks source link

Huge Router Refactor + New Data Paradigm + Preloading #312

Closed ryansolid closed 9 months ago

ryansolid commented 9 months ago

This PR implements the RFC I posted a few weeks back: https://github.com/solidjs/solid-router/discussions/306

See the updated Readme: https://github.com/solidjs/solid-router/blob/next/README.md

I believe I've implemented the RFC plus some learnings and incorporated the feedback.

Just doing some final testing/finishing touches.

gbj commented 9 months ago

One higher-level thing I'm curious about: This shifts things like <Outlet> away from using context, allowing you to render nested routes on the server without rendering the whole page etc., but <A> still relies on context for its resolved path/active route matching, useNavigate() and other hooks rely on context, etc. I'm curious how these work or don't with islands: i.e., if you useNavigate() in an island does it throw, or is the plan to have an island router context provider in the future, or something else?

ryansolid commented 9 months ago

@gbj

One higher-level thing I'm curious about: This shifts things like <Outlet> away from using context, allowing you to render nested routes on the server without rendering the whole page etc., but <A> still relies on context for its resolved path/active route matching, useNavigate() and other hooks rely on context, etc. I'm curious how these work or don't with islands: i.e., if you useNavigate() in an island does it throw, or is the plan to have an island router context provider in the future, or something else?

Islands can still have context.. like the client part. The server part doesn't want it. Context can exist on the server on initial render because we render the whole thing. After the fact we never render the Islands. So capital A can only be used in Islands. Or rather is an Island itself. All the use hooks only work in Islands. When we are ready to explore Hybrid routing again in that mode when we are in the noHydrate scope calls to useContext will throw. I just haven't done that yet because the router isn't Islands safe yet. But it will be in the future. For now we only do the initial render, as we don't have hybrid routing so this restriction doesn't matter yet.

TheElegantCoding commented 9 months ago

please update the doc i dont get it how to use the new route