Table of Contents

Class HtmxResponseHeaderNames

Namespace
Ramstack.HtmxToolkit
Assembly
Ramstack.HtmxToolkit.dll

Defines constants for the well-known names of HTMX response headers.

public static class HtmxResponseHeaderNames
Inheritance
HtmxResponseHeaderNames
Inherited Members

Examples

// A page on another origin loads fragments from this application. The browser hides
// cross-origin response headers from HTMX unless the server exposes them.
builder.Services.AddCors(options => options.AddPolicy("htmx", policy => policy
    .WithOrigins("https://app.example.com")
    .AllowAnyHeader()
    .WithExposedHeaders(
        HtmxResponseHeaderNames.Trigger,
        HtmxResponseHeaderNames.Retarget,
        HtmxResponseHeaderNames.Reswap)));

Remarks

For more information, see HTMX Response Headers Reference.

Fields

Location

The HX-Location header performs a client-side redirect without a full-page reload.

public const string Location = "HX-Location"

Field Value

string

PushUrl

The HX-Push-Url header pushes a new URL onto the browser's history stack.

public const string PushUrl = "HX-Push-Url"

Field Value

string

Redirect

The HX-Redirect header performs a client-side redirect with a full-page reload.

public const string Redirect = "HX-Redirect"

Field Value

string

Refresh

The HX-Refresh header performs a full-page refresh when its value is "true".

public const string Refresh = "HX-Refresh"

Field Value

string

ReplaceUrl

The HX-Replace-Url header replaces the current URL without pushing a new entry to the browser's history stack.

public const string ReplaceUrl = "HX-Replace-Url"

Field Value

string

Reselect

The HX-Reselect header specifies a CSS selector that determines which part of the response is swapped in.

public const string Reselect = "HX-Reselect"

Field Value

string

Reswap

The HX-Reswap header specifies how the response is swapped into the DOM.

public const string Reswap = "HX-Reswap"

Field Value

string

Retarget

The HX-Retarget header specifies a CSS selector that changes the target of the content update.

public const string Retarget = "HX-Retarget"

Field Value

string

Trigger

The HX-Trigger header triggers client-side events.

public const string Trigger = "HX-Trigger"

Field Value

string

TriggerAfterSettle

The HX-Trigger-After-Settle header triggers client-side events after the settle step.

public const string TriggerAfterSettle = "HX-Trigger-After-Settle"

Field Value

string

Remarks

Supported only in HTMX 1.x and 2.x.

TriggerAfterSwap

The HX-Trigger-After-Swap header triggers client-side events after the swap step.

public const string TriggerAfterSwap = "HX-Trigger-After-Swap"

Field Value

string

Remarks

Supported only in HTMX 1.x and 2.x.