Read URLs as structured slice data

Omit href from location-element to read the current page URL. Add live when history, hash, or navigation changes must update the slice and UI. Supply href to parse another URL without changing the page.

The slice exposes URL fields such as href, hostname, pathname, search, and hash. Repeated query parameters are available through paramEntries and preserve all values.

The plain HTML controls below change browser state outside the DCE. Compare the live reader with the initial-only reader, then try the browser's Back and Forward buttons. A native GET submission reloads the document, so both readers start again from that new URL.

See also

Set the page URL with location-element

Resolve module and resource URLs