Next.js Discord

Discord Forum

Custom error page not working

Answered
Yellowhead catfish posted this in #help-forum
Open in Discord
Yellowhead catfishOP
I did as written in the documentation, created a pages folder inside it 404.js, but still, when I go to a non-existent page, the standard next.js page

27 Replies

Yellowhead catfishOP
oops
But what if I set it to No when creating the project?
@gin are u using pages router?
Yellowhead catfishOP
or how to configure this for App routing
@Yellowhead catfish
I see you are using "use client" which means you wanted app router
but your second screenshot tells me that you completely messed up your folder structure
Answer
rename your file to not-found.js and place it under src/app/not-found.js
basically where your root layout.tsx
@California pilchard shouldn't the file end with `.jsx` ?
no .js is correct
.js, .jsx, .tsx all work. .ts won't work.
Yellowhead catfishOP
I found a solution to the problem: for error 404 you can create a not-found.js file in /app and to handle any others use React.FC<ErrorPageProps>
@gin i told u above :)
Yellowhead catfishOP
Yes, but I googled this yesterday before your answer. Thanks anyway
I just can't mark your answer as correct.
although this may be due to the blocking of discord in Russia...
ok I'll try from my phone
this is weird
russia blocking stuff really?
@gin russia blocking stuff really?
Yellowhead catfishOP
Yes. We have a very strange and stupid thing like Roskomnadzor, from the moment you know what began, they began to block all non-Russian social networks and services for the most stupid reasons. Now in Russia, only Reddit and Twitch are accessible without a VPN (and even Twitch is under threat of blocking)
Therefore, just to write here, I need to turn on VPN :p
I'm afraid that everything will come to the point that the NPM servers will be blocked and we won't even be able to register npm install XD
lmao