history
objects may be used to programmatically change the current location
using the following methods:
history.push(to: To, state?: State)
history.replace(to: To, state?: State)
history.go(delta: number)
history.back()
history.forward()
An example:
// Push a new entry onto the history stack.
history.push("/home");
// Push a new entry onto the history stack with a query string
// and some state. Location state does not appear in the URL.
history.push("/home?the=query", { some: "state" });
// If you prefer, use a location-like object to specify the URL.
// This is equivalent to the example above.
history.push(
{
pathname: "/home",
search: "?the=query",
},
{
some: state,
}
);
// Go back to the previous history entry. The following
// two lines are synonymous.
history.go(-1);
history.back();