Progammatically navigates the Browser to the given href, and pushes a new History state
NOTE: If your <head> element contains a <base> element, goto will read it as the base url
As a simple example:
import {goto} from"svelte-commons/lib/util/browser";
// Navigate to a page decending from the current origin
goto("/shopping-cart/item-274");
// Similar to above, by updates the Browser's hash string instead
goto("/shopping-cart/item-274", {hash: true});
You can also replace the current History state:
import {goto} from"svelte-commons/lib/util/browser";
// Same above, but replacing current History state
goto("/shopping-cart/item-274", {replace: true});
Finally, you can navigate to entirely different websites:
import {goto} from"svelte-commons/lib/util/browser";
// This will cause a full page reload while navigating
goto("https://google.com");
Progammatically navigates the Browser to the given
href
, and pushes a new History stateAs a simple example:
import {goto} from "svelte-commons/lib/util/browser"; // Navigate to a page decending from the current origin goto("/shopping-cart/item-274"); // Similar to above, by updates the Browser's hash string instead goto("/shopping-cart/item-274", {hash: true});
You can also replace the current History state:
import {goto} from "svelte-commons/lib/util/browser"; // Same above, but replacing current History state goto("/shopping-cart/item-274", {replace: true});
Finally, you can navigate to entirely different websites:
import {goto} from "svelte-commons/lib/util/browser"; // This will cause a full page reload while navigating goto("https://google.com");