The History API lets you control browser history and move through it programmatically.
history.back(); // Go back
history.forward(); // Go forward
history.go(-2); // Go back 2 pages
// Add history entry without page load
history.pushState({ page: 2 }, "", "/page2");
Single-page apps use pushState to update the URL without reloading.