hx-method
The hx-method attribute specifies the HTTP method (verb) to use for the request.
Syntax
<button hx-action="/api/users" hx-method="post">
Create User
</button>
Notes
- Valid values:
get,post,put,patch,delete - If no method is specified, defaults to
get hx-methodis typically used withhx-action- The shorthand attributes like
hx-get,hx-post, etc. can be used instead
Examples
<!-- Explicit method specification -->
<button hx-action="/api/users/123" hx-method="delete">
Delete User
</button>
<!-- Equivalent using hx-delete shorthand -->
<button hx-delete="/api/users/123">
Delete User
</button>
<!-- Default to GET if no method specified -->
<button hx-action="/api/users">
Get Users
</button>