I don't need to keep track of it, because that state is embedded in the hypermedia ie HTML page itself. Eg, I implemented a pagination component in htmx. It has a 'prev' button, a page display, and a 'next' button. If I'm on page 1 and I press the 'next' button, then I have my backend server respond with the next page and also a re-rendered pagination component with all three elements now pointing at their new correct pages.
So before clicking 'next':
<a disabled>prev</a>
<span>Page 1</span>
<a href="/page/2" hx-get="/page/2">next</a>
After clicking 'next': <a href="/page/1" hx-get="/page/1">prev</a>
<span>Page 2</span>
<a href="/page/3" hx-get="/page/3">next</a>