nextstepjs
Version:
Lightweight onboarding library for Next.js
16 lines (15 loc) • 433 B
JavaScript
'use client';
import { useRouter, usePathname } from 'next/navigation';
export const useNextAdapter = () => {
const router = useRouter();
const pathname = usePathname();
const isClient = typeof window !== 'undefined';
return {
push: (path) => {
if (isClient) {
router.push(path);
}
},
getCurrentPath: () => (isClient ? pathname || '/' : '/'),
};
};