Skip to content

not-found.js is always rendered #87174

@jorrit

Description

@jorrit

Link to the code that reproduces this issue

https://github.com/jorrit/nextjs-test-not-found

To Reproduce

  1. Clone https://github.com/jorrit/nextjs-test-not-found
  2. npm ci, npm run dev
  3. Visit http://localhost:3000
  4. Notice that NotFound is rendered is written to the server console

Current vs. Expected behavior

Currently, the not-found.tsx file is rendered for every page view. I want to use this file to run a query to see if a redirect exists for the current URL. This is not possible when this component is rendered on every pageview.

Also, it seems like a waste of effort.

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Pro
  Available memory (MB): 32469
  Available CPU cores: 20
Binaries:
  Node: 22.18.0
  npm: 11.1.0
  Yarn: 1.22.22
  pnpm: 9.15.4
Relevant Packages:
  next: 16.0.10 // Latest available version is detected (16.0.10).
  eslint-config-next: N/A
  react: 19.2.1
  react-dom: 19.2.1
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not Found

Which stage(s) are affected? (Select all that apply)

next start (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not FoundRelated to the not-found.tsx file or the notFound() function.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions