Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link not working in notFound component nextjs 13.4

I created a not-found.tsx component in my app directory in nextjs 13.4 which works fine when I enter wrong route as seen below:

import Link from 'next/link'

function NotFound() {
  
  return (
    <section>
      
      404, page not found
      <br/>
      <Link href="/">Back to HomePage</Link>

    </section>
  )
}

export default NotFound

But when I click the link to go back to the homepage, I still get the 404 page not found page.

I tried using the useRouter to navigate away but got the same problem. I notice the issue is as a result of not-found being in the app directory with the homepage

project structure

So how do I navigate from the not found page to the home page?

like image 414
Charles Ayomike Avatar asked Sep 06 '25 03:09

Charles Ayomike


1 Answers

this was a bug in nextjs 13.4 and it has been fixed, just install the latest version of next npm install next@latest react@latest react-dom@latest. and everything should work fine.

like image 51
Charles Ayomike Avatar answered Sep 08 '25 01:09

Charles Ayomike