The hx-action attribute specifies the URL that will receive the request.
Syntax
<button hx-action="/api/users" hx-method="post"> Create User </button>
Notes
hx-actionis typically used withhx-methodto specify both the URL and HTTP method- The shorthand attributes like
hx-get,hx-post, etc. combine both URL and method - Use
hx-action+hx-methodwhen you need dynamic method selection
Examples
<!-- Using hx-action with hx-method --> <button hx-action="/api/users" hx-method="post"> Create User </button> <!-- Equivalent using hx-post shorthand --> <button hx-post="/api/users"> Create User </button>