navigate
Programmatically navigate to a route.
/** * Programmatically navigate to a route. * * @param path The route pattern or path (e.g. "/user/:id"). * @param params (optional) Object of dynamic params to fill in the path. * @param query (optional) Object of query parameters. * @param opts (optional) { replace?: boolean } to replace instead of push history. */navigate( path: string, params?: Record<string, string>, query?: Record<string, string>, opts?: { replace?: boolean })
Supports dynamic params and query objects.
import { navigate } from "@hellajs/router";
// Go to /aboutnavigate("/about");
// Go to /user/123?tab=profilenavigate("/user/:id", { id: "123" }, { tab: "profile" });
// Replace current history entrynavigate("/login", {}, {}, { replace: true });