get props passed to component inside getServerSideProps

57 Views Asked by At

In Next.js, let's assume we have this component:

<MyComponent width=150 />

Inside this component, I know how to fetch data inside getServerSideProps

export const getServerSideProps: GetServerSideProps = async (context) => {
    const data = await fetchData() as DataInterface;
    
    return { props: { data: data } }
}

Inside the main function of the component, I also know how to get access to the fetched data props.

export default function MyComponent( {data}: InferGetServerSidePropsType<typeof getServerSideProps>) { etc...

Now, in the context of this component, how can I also access the "width" prop passed to the MyComponent component?

Thanks

0

There are 0 best solutions below