29 lines
675 B
TypeScript
29 lines
675 B
TypeScript
"use client";
|
|
|
|
import { useRouter } from "next/navigation";
|
|
import { useMemo } from "react";
|
|
import { startActionLoading } from "@/lib/global-action-loading";
|
|
|
|
export function useAppRouter() {
|
|
const router = useRouter();
|
|
|
|
return useMemo(
|
|
() => ({
|
|
...router,
|
|
push: (...args: Parameters<typeof router.push>) => {
|
|
startActionLoading();
|
|
return router.push(...args);
|
|
},
|
|
replace: (...args: Parameters<typeof router.replace>) => {
|
|
startActionLoading();
|
|
return router.replace(...args);
|
|
},
|
|
refresh: () => {
|
|
startActionLoading();
|
|
return router.refresh();
|
|
},
|
|
}),
|
|
[router],
|
|
);
|
|
}
|