type of page props nextjs
Answered
American black bear posted this in #help-forum
American black bearOP
Hello everyone,
is there a better way to do the following, eg with a built in props. I can't find one
is there a better way to do the following, eg with a built in props. I can't find one
export type ExercisePageProps = {
params: { id?: Exercise["id"] };
searchParams: { from?: string; to?: string };
}; // surely there is a built in props for that
const Page = async (unsafeProps: ExercisePageProps) => {
return (...)
}
Answered by risky
Nextjs currently doesn't have a method for knowing the params (for dynamic routes)... we have a community one tho https://discord.com/channels/752553802359505017/1159366767358005278/1159366839298691084
3 Replies
@American black bear Hello everyone,
is there a better way to do the following, eg with a built in props. I can't find one
tsx
export type ExercisePageProps = {
params: { id?: Exercise["id"] };
searchParams: { from?: string; to?: string };
}; // surely there is a built in props for that
const Page = async (unsafeProps: ExercisePageProps) => {
return (...)
}
Nextjs currently doesn't have a method for knowing the params (for dynamic routes)... we have a community one tho https://discord.com/channels/752553802359505017/1159366767358005278/1159366839298691084
Answer
You would still have to type searchparams as know one knows what it is
American black bearOP
yeah that makes sense. Thanks for your help 🙌