Debian Codegraph @

www/src/content/reference/01-attributes/30-hx-action.md

raw symbols SCIP
1 ---
2 title: "hx-action"
3 description: "Specifies the URL to receive the request"
4 ---
5
6 The `hx-action` attribute specifies the URL that will receive the request.
7
8 ## Syntax
9
10 ```html
11 <button hx-action="/api/users" hx-method="post">
12 Create User
13 </button>
14 ```
15
16 ## Notes
17
18 * `hx-action` is typically used with [`hx-method`](/reference/attributes/hx-method) to specify both the URL and HTTP method
19 * The shorthand attributes like [`hx-get`](/reference/attributes/hx-get), [`hx-post`](/reference/attributes/hx-post), etc. combine both URL
20 and method
21 * Use `hx-action` + `hx-method` when you need dynamic method selection
22
23 ## Examples
24
25 ```html
26 <!-- Using hx-action with hx-method -->
27 <button hx-action="/api/users" hx-method="post">
28 Create User
29 </button>
30
31 <!-- Equivalent using hx-post shorthand -->
32 <button hx-post="/api/users">
33 Create User
34 </button>
35 ```