According to the NextJS 13 documentation, writing the async components is the new way of prefetching some data on the server - all the getStaticProps
, getInitialProps
, and getServerSideProps
should be replaced by async components.
My problem is that I have a situation where I need to access the path
in order to prefetch some data (I am loading metadata for the page from the server). Previously, I was using the NextApiRequest
object that was passed as a parameter to the getServerSideProps
function to retrieve the information about the path. I am unsure, however, how can I access this information in my async component.
I have tried to use the 'useRouter' hook to retrieve the path
information, however hooks are not allowed on the Server components.