nextstepjs
Version:
Lightweight onboarding library for Next.js
20 lines (16 loc) • 493 B
text/typescript
'use client';
import { useNavigate, useLocation } from '@remix-run/react';
import type { NavigationAdapter } from '../../types/navigation';
export const useRemixAdapter = (): NavigationAdapter => {
const navigate = useNavigate();
const location = useLocation();
const isClient = typeof window !== 'undefined';
return {
push: (path: string) => {
if (isClient) {
navigate(path);
}
},
getCurrentPath: () => (isClient ? location.pathname : '/'),
};
};