NavigationStore.forward()method
Navigate forward to a URL, pushing a new browser history entry.
forward(possible: PossibleURL): void
new NavigationStore(url: PossibleURL = typeof window === "undefined" ? "/" : window.location.href, base?: PossibleURL)
| Param | Type | |
|---|---|---|
url | PossibleURL | Values that can be converted to a URL instance. Defaults to typeof window === "undefined" ? "/" : window.location.href |
base | PossibleURL | Values that can be converted to a URL instance. |
| Return | |
|---|---|
NavigationStore | Store holding the current navigation URL and driving browser history. |
| Property | Type | |
|---|---|---|
.transition | TransitionTypenull | Transition type of the next URL change. null means no transition. <Navigation> reads it, then sets it back to "forward". Defaults to "forward" |
Store holding the current navigation URL and driving browser history.
URLStore; the current location is its value.forward() pushes a new history entry; redirect() replaces the current one.back() pushes a new history entry like forward(), but <Navigation> animates it as a back transition.The store holding the current navigation URL and driving browser history. It extends URLStore — the current location is its value — and is owned by <Navigation>. Reach for it via requireNavigation() rather than constructing your own.
Things to know:
forward() pushes a new browser history entry; redirect() replaces the current one. Both resolve the destination against the store's base.back() pushes a new browser history entry like forward(), but <Navigation> gives it the "back" transition type, so the page slides back. It does not go back in the browser history, so it works when the page was opened directly.shelving/store URLStore, so components can subscribe to it for re-renders.import { requireNavigation } from "shelving/ui";
function LogoutButton() {
const nav = requireNavigation();
return <Button onClick={() => nav.redirect("/login")}>Log out</Button>;
}Constructed directly only when wiring navigation by hand (e.g. tests):
import { NavigationStore } from "shelving/ui";
const nav = new NavigationStore("/");
nav.forward("/home");Navigate forward to a URL, pushing a new browser history entry.
forward(possible: PossibleURL): void
Redirect to a URL, replacing the current browser history entry.
redirect(possible: PossibleURL): void
Navigate back to a URL, pushing a new browser history entry with the "back" transition type.
back(possible: PossibleURL): void