'use client';

import { useRouter } from 'next/navigation';

export default function useNavigate() {
  const router = useRouter();

  return (href, options = {}) => {
    if (typeof href === 'number') {
      if (href === -1) router.back();
      return;
    }

    if (!href || href === '#') return;

    if (options?.replace) {
      router.replace(href);
      return;
    }

    router.push(href);
  };
}
