dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

File system based routing

Open itsezc opened this issue 2 years ago • 5 comments

Specific Demand

Similar to NextJS, SvelteKit and many other JS based frameworks: it would be nice to have file based routing to aid DX, this could be opt-in as some would prefer to have the existing implementation of a router.

itsezc avatar Apr 01 '23 16:04 itsezc

This would be a great addition to the ecosystem, but I don't think it belongs in the main Dioxus router library. File based routing is typically part of a more opinionated metaframework. It should be possible to implement this with the existing router. Something like this could definitely be interesting in a Dioxus metaframework (like https://github.com/ahecha-co/ahecha).

ealmloff avatar Apr 01 '23 17:04 ealmloff

Since this is more relevant to Tokamak, could we reopen this and move it to the https://github.com/DioxusLabs/tokamak repo, thanks.

itsezc avatar Jul 11 '23 05:07 itsezc

Since I closed this PR, dioxus-fullstack was created which is much more like a metaframework. This could fit in that crate.

ealmloff avatar Jul 11 '23 22:07 ealmloff

Would love for someone to champion this

Since I closed this PR, dioxus-fullstack was created which is much more like a metaframework. This could fit in that crate.

Not sure if dioxin fullstack has its own roadmap / milestone, perhaps this can be tracked with that in mind?

itsezc avatar Dec 27 '23 21:12 itsezc

Would love for someone to champion this

I'm not sure if file based routing would be a good fit with the type safe router we currently have. The current router uses an enum to represent routes. We need type information for that enum to determine how to parse the route. We also need a type for the route to make links typesafe.

It isn't clear:

  • What would route definitions look like with types. How are layouts defined (files with specific names + component names)?
  • How typed routes should be derived from the routes
  • If it worth giving up a lot of transparency for slightly easier routes once you know the file based syntax

I think file system based routes would give up a lot of transparency about the structure of the Route enum which would make it more difficult to work with.

Not sure if dioxin fullstack has its own roadmap / milestone, perhaps this can be tracked with that in mind?

Dioxus fullstack is tracked with the dioxus roadmap here.

ealmloff avatar Dec 28 '23 18:12 ealmloff