| 1 | --- |
| 2 | title: "HX-Request" |
| 3 | description: "Indicates a request was made by htmx" |
| 4 | --- |
| 5 | |
| 6 | The `HX-Request` header indicates the request was made by htmx. |
| 7 | |
| 8 | It's value is always `true`. |
| 9 | |
| 10 | ## Syntax |
| 11 | |
| 12 | ```http |
| 13 | HX-Request: true |
| 14 | ``` |
| 15 | |
| 16 | ## Usage |
| 17 | |
| 18 | Use it to detect htmx requests on the server: |
| 19 | |
| 20 | ```python |
| 21 | if request.headers.get('HX-Request'): |
| 22 | # This is an htmx request |
| 23 | return render_template('partial.html') |
| 24 | else: |
| 25 | # This is a regular browser request |
| 26 | return render_template('full.html') |
| 27 | ``` |