Next.js Discord

Discord Forum

Incorrect not-found.tsx behaviour

Unanswered
Tonkinese posted this in #help-forum
Open in Discord
TonkineseOP
I am using the app router.

I have a not-found.tsx file at the route of app.

When notFound() is invoked the not-found.tsx renders, but when there is a url mistype the generic black next 404 is rendered.

How do I fix this behaviour?

4 Replies

Western paper wasp
I ran into some issues with certain routing structures (route groups) where I had to duplicate not-found.tsx and default.tsx files to make the proper not-found render
Like assuming you have your main not-found in app/not-found.tsx I also had to create some files like:

app/(group)/@parallel/not-found.ts
export { default } from '../../not-found';


app/(group)/@parallel/default.ts
export { default } from '../../not-found';


app/(group)/default.ts
export { default } from '../not-found';
because I found some cases the app router wasn’t using my not-found when I thought it should’ve been
not sure if it’s a bug or the result of some documented behavior