Replies: 6 comments 3 replies
-
Not right now I think. The docs define it on spot: type PageProps = {
params: { slug: string };
searchParams?: { [key: string]: string | string[] | undefined };
} One slight tricky, not impossible, but tricky, thing is that Since an specific type or interface, is not documented at the moment, I'd just take it from the code snippet in https://beta.nextjs.org/docs/api-reference/file-conventions/page |
Beta Was this translation helpful? Give feedback.
-
Would love to have a reliable type that comes from |
Beta Was this translation helpful? Give feedback.
-
IMHO it's worth making it a generic so you can specify either a string or string[] for slugs because you might want to use catch-all routes: export interface NextPageProps<SlugType = string> {
params: { slug: SlugType };
searchParams?: { [key: string]: string | string[] | undefined };
} |
Beta Was this translation helpful? Give feedback.
-
My temporary solutionFirst defined a generic interface:export interface ServerSideComponentProp<
Params,
SearchParams = undefined,
> {
params: Params;
searchParams: SearchParams;
} Then in my server side component:// ./app/dashboard/[dashboardId]/page.tsx
import { ServerSideComponentProp } from './server-side-components-prop';
export default function Dashboard({
params,
}: ServerSideComponentProp<{ dashboardId: string }>) {
return <div>{params.dashboardId}</div>;
} |
Beta Was this translation helpful? Give feedback.
-
I'm curious, theoretically nextjs should provide it. |
Beta Was this translation helpful? Give feedback.
-
https://nextjs.org/docs/app/building-your-application/optimizing/metadata |
Beta Was this translation helpful? Give feedback.
-
I recently discovered that the react server components in the app directory are passed a
params
object in the props.I was wondering, is there a Typescript type for a react server component's props?
Beta Was this translation helpful? Give feedback.
All reactions