3

I'm using next 13.4.4 with app router. I've added not-found.tsx component to app directory, basically just copied code from next documentation:

import Link from 'next/link'
 
export default function NotFound() {
  return (
    <div>
      <h2>Not Found</h2>
      <p>Could not find requested resource</p>
      <p>
        View <Link href="/">all posts</Link>
      </p>
    </div>
  )
}

The problem is, when I navigate to not existing route, 404 page renders correctly, but inifintely reloads.

tl;dr: I've wrote not-found.tsx component. Expected it to just display not found page, but it reloads infinitely.

1
  • 1
    Is this in development mode? If so, that's expected behaviour for the 404 page. It shouldn't behave like that in production. Commented Jul 2, 2023 at 13:43

1 Answer 1

8

"Is this in development mode? If so, that's expected behaviour for the 404 page. It shouldn't behave like that in production."

Thanks juliomalves. Yeah, it was in development mode.

p.s. Weird expected behavior imho, idk why they made it like that.

2
  • 4
    The reason why it's been designed this way is because in development ENV you might be trying to access a page you haven't created yet. For this reason, the server refreshes to check if the page you try to reach has been created and avoid you being stuck on the 404 page. More details here: github.com/vercel/next.js/discussions/…
    – Sunamin34
    Commented Jul 21, 2023 at 9:18
  • Thanks i was about to ask this question.
    – AP aul
    Commented Aug 10, 2023 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.