The hx-method attribute specifies the HTTP method (verb) to use for the request. It is typically paired with hx-action to separate the URL from the method.
Syntax
<button hx-action="/api/users" hx-method="post"> Create User </button>
Priority
hx-method overrides both formmethod on submitter buttons and the native method attribute on forms:
<!-- Always sends PUT regardless of native method or submitter --> <form hx-action="/items/1" hx-method="put" method="post"> <input name="name"> <button>Save</button> </form>
A shorthand attribute such as hx-post sets the URL and the method together, so it wins over hx-method:
<!-- Sends POST. The hx-method value is ignored. --> <button hx-post="/items" hx-method="put">Save</button>
When hx-method is omitted, htmx falls back to formmethod, then native method, then GET. See hx-action Method Resolution for the full chain.
Notes
Example
<!-- Explicit method --> <button hx-action="/api/users/123" hx-method="delete"> Delete User </button> <!-- Equivalent shorthand --> <button hx-delete="/api/users/123"> Delete User </button> <!-- Server-rendered dynamic method --> <form hx-action="/resources/${id}" hx-method="${method}" hx-target="this"> <input name="name"> <button>${action_label}</button> </form>