Next.js Discord

Discord Forum

Typed query params?

Unanswered
Southern rough shrimp posted this in #help-forum
Open in Discord
Southern rough shrimpOP
We can type Route params in App router (/a/[id]/b) but how about how to type query params (?bla=123)?

3 Replies

@Southern rough shrimp
searchParams: { bla: string | string[] | undefined };
then just check for each and return/modify as needed
remember to always check for those 3, just to be safe