Frontend JS-Router
Due to the JavaScript Router
being very convenient, it is natural to want to have the same functionality in
the frontend.
This is really hard, however. The PageRouter
(and the associated page matching) is one of the most complex parts
of the Mayd internals. That is in part due to the topic being quite complicated, but mainly because of the fact, that
both the URL matching and generation has a lot of context (both data as well as use cases).
This would mean, that for a page router to be feasible in the frontend, you would need to serialize the complete page tree as well as all attached information to the JS. While this is technically possible, it would lead to a really bad performance due to the data traffic and parsing overhead.
Always generate the URLs in Mayd and just pass them to the frontend as string
s.
You can either use global JavaScript data or a local DataContainer
to
embed these URLs.
“What about a regular router?”
Normally, a regular router is not worth the cost, as you need to pass the complete router as well as the route definitions, just to generate 3 URLs in the end. Just generated them in advance and pass them as strings.
Also, the backend of the JS router can’t differentiate between route domains right now, so you would always dump all routes, in frontend as well as backend.