I have the following code in /src/spp/page.tsx:
import { getPayload } from 'payload'
import config from '@payload-config'
import { notFound } from 'next/navigation'
const payload = await getPayload({ config })
const settings = await payload.findGlobal({ slug: 'settings' })
const pageQueryRes = await payload.find({
collection: 'pages',
where: {
slug: {
equals: '',
},
},
})
if (pageQueryRes.docs.length == 1) {
// TODO: Implement notFound
notFound()
}
const page = pageQueryRes.docs[0]
export const metadata = {
title: settings?.siteTitle || 'Test',
description: settings?.siteDescription || 'Generated by Next.js',
}
export default async function Page() {
console.log(page)
return <div></div>
}
However when the notFound() function is invoked I get the following error:
Error: Next.js navigation API is not allowed to be used in Pages Router.
at notFound (webpack-internal:///(rsc)/./node_modules/next/dist/client/components/not-found.js:28:19)
at eval (webpack-internal:///(rsc)/./src/app/(frontend)/page.tsx:32:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)