htmx/www/attributes/hx-push-url.md
acnebs d01025823e Rename custom HTTP headers to no longer start with X-
This convention is deprecated, as per this RFC from the IETF: 
https://tools.ietf.org/html/rfc6648
2020-05-28 01:29:51 +01:00

671 B

layout title
layout.njk </> htmx - hx-push-url

hx-push-url

The hx-push-url attribute allows you to "push" a new entry into the browser location bar, which creates a new history entry, allowing back-button and general history navigation. The possible values of this attribute are true and false.

Here is an example:

<div hx-get="/account" hx-push-url="true">
  Go to My Account
</div>

This will cause htmx to snapshot the current DOM to localStorage and push the URL `/account' into the browser location bar.

Notes

  • hx-push-url is inherited and can be placed on a parent element
  • see also the HX-Push response header