NextJS Vérifiez le chemin 404

import { useRouter } from "next/router";
function Layout() {
  const router = useRouter();
  // If you are not using a custom 404 page, 
  // the default router.pathname is _error so
  if ( router.pathname === "/_error" ){
    // 404
  } 
  return "Whatever...";
}
KostasX