We have duplicate routing on the server side so that we can send 404s for obviously invalid routes, but for stateful routes you have to make some tradeoffs.
Say you have a route like
You can validate the UUID quickly, but verifying that piece of content with that UUID exists in a database is slow.
For users we prefer speed over the status code so we only validate the UUID and they end up seeing a “Not Found” page in the app with a 200 status code.
For bots we prefer correctness so we validate UUID and then make sure the content exists before returning.
Meta tags come into this as well, and they have to be done on the server too, it would be great to be able to server-render them and transfer some initial state to the client!
It is possible to re-use server rendered DOM for the app if you are using
Browser.element, but it is due to an implementation detail and probably shouldn’t be relied on, when you’re using
Browser.application it creates a new
body node, replacing the existing one, but with
Browser.element it diffs the node you give it and applies patches. If you can seed the initial state through flags and match the server state you can avoid the flash you would get when the server rendered DOM is replaced by Elm’s.