next-era
Version:
Welcome to **Next Era**! A comprehensive library designed to supercharge your **Next.js** applications with powerful utilities and significant performance optimizations. Build faster, more efficient, and feature-rich Next.js projects with ease.
47 lines (46 loc) • 1.41 kB
TypeScript
import { UseRouterType } from "./lib/definitions.js";
/**
* Enhanced useRouter of next/navigation, the hook's allow to pass a object with path and option to push or convert to string URL by toHref.
* The object's path can be a template string with params and searchParams.
* Example:
* ```tsx
* const { push } = useRouter();
*
* return (
* <>
* <div
* onClick={() =>
* push({
* path: "/example/route/id/:id/detail",
* options: {
* params: { id },
* searchParams: { page: 1, limit: 10 },
* },
* })
* }
* />
* <Link
* href={toHref({
* path: "/example/route/id/:id/detail",
* options: {
* params: { id },
* searchParams: { page: 1, limit: 10 },
* },
* })}
* />
* </>
* );
* ></div>
* ```
* @returns standard Next useRouter's function, toHref, push
*/
declare const useRouter: () => {
toHref: (href: UseRouterType) => string;
push: (href: UseRouterType) => void;
back(): void;
forward(): void;
refresh(): void;
replace(href: string, options?: import("next/dist/shared/lib/app-router-context.shared-runtime.js").NavigateOptions): void;
prefetch(href: string, options?: import("next/dist/shared/lib/app-router-context.shared-runtime.js").PrefetchOptions): void;
};
export default useRouter;