htmx 4.0 is under construction — migration guide

HX-Current-URL

Contains the URL of the browser when the request was made

The HX-Current-URL request header contains the browser’s URL when the request was made.

Use it to understand page context or build relative URLs.

Syntax

The header is included as follows:

HX-Current-URL: https://example.com/products

Usage

Read the current URL from the request:

current_url = request.headers.get('HX-Current-URL')