Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

nextjs check path 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...";
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #nextjs #check #path
ADD COMMENT
Topic
Name
1+8 =