Next.js Discord

Discord Forum

How to call `notFound` in client-component?

Unanswered
ncls. posted this in #help-forum
Open in Discord
Hello,

How can I display the not-found page in a client-component? I have an API call and if it returns 404, I want to display the not-found page.

8 Replies

Well the not-found page will show up anytime you go to a route that doesn't exist so when handling the 404 api call, you can redirect the user to a page that doesn't exist
Yeah, but that's not clean if I redirect them
By clean do you mean that it doesn't give the user much context as to what the problem is?
No, I don't care about that
But I guess I thought the wrong way
I should just display a component then
Thank you
No problem