3 ms·
> Anybody can write some HTML with some anchor tags and tie it to some routes declared in a server-side routing file. The back button will work. History will wo
by wesleytodd 10y ago
> Anybody can write some HTML with some anchor tags and tie it to some routes declared in a server-side routing file. The back button will work. History will work. Refresh will work. Copy-and-pasting the URL into an email will work. It's so easy that even I can do it.
The solution I use[1], and disclaimer also wrote, was targeted directly at server rendered SPA's to follow closely with these ideals. Layers over native anchor tags, just barebones handles the link clicking and uses Express routing which is obviously back end compatible.
[1] https://github.com/wesleytodd/nighthawk https://github.com/wesleytodd/nighthawk
- wesleytodd 10y agoAlso, forgot to mention, nighthawk also solves the edge cases mentioned toward the end: * ctrl-clicking to open a new tab * shift-clicking to open a new window * alt-clicking * non-left-clicking * target attribute in <a> * mailto: in href
- nojvek 10y agoThis is awesome. 8kb is still pretty ridiculous for a routing library. I do like that there is no special integration. A href links just work.
- wesleytodd 10y agoAgreed, but it is still smaller than the competitors. I would love to reduce it even more, but there is very little concern for file size in express' router since it is server side. Also, I believe it can be made smaller with one of the other bundlers. Browserify is not the most size conscious choice, it just happens to be the one I have the most experience with.