The new way with Next.js 15+ would be to use the router in "next/navigation" when calling from the client side ('use client'
) like this:
For the import:
import { useRouter } from 'next/navigation';
In your React component:
const router = useRouter();
router.replace(...);