--- title: "hx-config" description: "Configures request behavior with JSON" --- The `hx-config` attribute allows you to configure request behavior using JSON. ## Syntax ```html ``` ## Available Options | Option | Type | Description | Example | |---------------|---------|----------------------------------------------------------|---------------| | `timeout` | number | Request timeout in milliseconds | 5000 | | `credentials` | string | Fetch credentials mode: "omit", "same-origin", "include" | "include" | | `cache` | string | Fetch cache mode: "default", "no-cache", "reload", etc. | "no-cache" | | `redirect` | string | Fetch redirect mode: "follow", "error", "manual" | "follow" | | `referrer` | string | Referrer URL or "no-referrer" | "no-referrer" | | `integrity` | string | Subresource integrity value | "sha384-..." | | `validate` | boolean | Whether to validate form before submission | true | These options map to the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API). > **Security note:** The `mode` option is intentionally excluded from `hx-config`. It is always > reset to the global `htmx.config.mode` value (default: `"same-origin"`) to prevent injection > attacks from widening request scope. To change the fetch mode, set it globally via > `htmx.config.mode` or a `` tag. See the > [mode config reference](/reference/config/htmx-config-mode) and > [security best practices](/docs#best-practices) for details. ## Merging Configuration By default, child `hx-config` values replace parent configurations entirely. Use the `+` prefix to merge with parent config instead: ```html
``` The button inherits the timeout and adds a custom header. Without `+`, the child config replaces the parent config entirely. ## Examples ### Set timeout for slow endpoint ```html ``` ### Include credentials ```html ``` ### Disable cache ```html ```