UNPKG

nextstepjs

Version:

Lightweight onboarding library for Next.js

17 lines (16 loc) 457 B
'use client'; 'use no memo'; import { useNavigate, useLocation } from 'react-router'; export const useReactRouterAdapter = () => { const navigate = useNavigate(); const location = useLocation(); const isClient = typeof window !== 'undefined'; return { push: (path) => { if (isClient) { navigate(path); } }, getCurrentPath: () => (isClient ? location.pathname : '/'), }; };