Next.js Discord

Discord Forum

searchParams is undenfined on production

Unanswered
Himalayan posted this in #help-forum
Open in Discord
HimalayanOP
Why searchParams is undefined when on the production? It's working fine on development. already google it but they recommend to use client. I want to server component instead. :/

export default async function TimelineDetailPage({ params, searchParams }: { params: { id: string }, searchParams?: { [key: string]: string | string[] | undefined } }) {

  let data = await prisma.timeline.findUnique({ where: { id: searchParams?.id ? Number(searchParams.id.toString()) : 100000 } })

  return (
    <>
      {
        (params.id == "new" || params.id == "edit") && (
          <div>
            <New timeline={data} />
          </div>
        )
      }
      {
        params.id == "detail" && <Detail timeline={data!} />
      }
    </>

  )
}

0 Replies