How to trigger the not found page manually
Answered
Asian paper wasp posted this in #help-forum
Asian paper waspOP
I have dynamic routing in my application. But there are only 4 possible routes. If the route is not in the possible routes, I want to trigger the not-found page.
Answered by Asian paper wasp
Ok I found it
import { notFound } from "next/navigation"
export default function Page() {
if (something) {
notFound()
}
}2 Replies
Asian paper waspOP
Ok I found it
import { notFound } from "next/navigation"
export default function Page() {
if (something) {
notFound()
}
}Answer
or use [
dynamicParams = false](https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams)