• alhazrod 19 hours ago

    I wish he had gone into more detail around 'A common critique of HTMX is that users lose the ability to use the “Back” button or share specific filtered views. In many frameworks, this requires complex series of state hooks to keep the URL in sync.'

    • yellowapple 18 hours ago

      That's what he addresses with “In the dashboard of this project, I solved this with a single attribute: hx-push-url="true".”, no?

      • yawaramin 11 hours ago

        He makes it sound like he did something special, but this is just something that htmx offers out of the box. In fact if he had used something like:

            <a href="/?page=2" hx-target="#dashboard-content" hx-boost="true">
              Next Page
            </a>
        
        Then he would have gotten the functionality out of the box without even using hx-push-url explicitly. And he would have gotten graceful degradation with a link that worked without JS and Ctrl/Cmd-click to open in a background tab.

        Also the article seems to be full of errors. Eg

        > In HTMX, if the server returns a 500 error, the browser might swap the entire stack trace or the generic error page into the middle of a table by default. This is a poor user experience.

        This is simply incorrect. By default htmx does not swap 4xx/5xx responses. Instead it triggers an error event in the DOM. Developers can choose to handle that event or they can choose to override the default behaviour and do a swap.