Skip to content

typing of unparsed SearchParams necessary? #522

Answered by franky47
rwieruch asked this question in General
Discussion options

You must be logged in to vote

The Next.js docs recommend specifying the keys you're interested in, but since you can technically receive anything, a more correct type would be Record<string, string | string[] | undefined>, which is conveniently exported by nuqs:

// page.tsx
import type { SearchParams } from 'nuqs/server'

type PageProps = {
  searchParams: SearchParams
}

export default function Page({ searchParams }: PageProps) {
  // ...
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@rwieruch
Comment options

Answer selected by rwieruch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants