0
Challenge · 48Routing & Data

Browser History

Coreused in ~60% of apps

Click a link in a single-page app and the URL changes, the Back button works, and the link is bookmarkable — yet the page never reloads. The browser's History API is the machinery that makes that possible, and every router is built on top of it.

Core idea. The History API lets JavaScript change the URL and the back/forward stack without a server round-trip: pushState adds an entry, replaceState swaps the current one, back()/forward() move the pointer, and a popstate event fires only when the user navigates the stack. Your router wraps all of this — you rarely call it directly.
Playground, this isn't a screenshot
URL/
popstate idle
history stack1 entry
0/ current
The session history is a stack with a pointer at the current entry. Try Push, Replace, then Back / Forward.
↑ play a little first, then dig in