schell / mogwai

The minimalist, obvious, graphical, web application interface
429 stars 26 forks source link

Isomorphic Routing Example #91

Closed cryptoquick closed 2 years ago

cryptoquick commented 2 years ago

One issue I've noticed with the SPA router is that it's using fragment-based routing instead of the History API. The problem with that is the fragment is never sent to the server on a request, and so it can't be used to route the app on the backend on SSR. But it's not immediately clear from the SPA routing example how to move to History-based routing.

It might be helpful to reference the Percy isomorphic routing example: https://github.com/chinedufn/percy/tree/master/examples/isomorphic

Notice they keep the app in one folder, and the client and server in separate folders.

schell commented 2 years ago

I think that's a good request. I've got it on my radar now, thanks.

bryanjswift commented 2 years ago

I'm not sure if it still works this way (it has been a while) but the multipage example used to do routing based on path (/ vs /404).

cryptoquick commented 2 years ago

This was good advice! I referenced the multipage code and made use of what I needed. This project supports SSR for both HTML and styles. It might be useful to look at for one way Mogwai could be used in a real-world project: https://github.com/Grayblock/grayblock-rs