Nice article. I was wondering how you could fetch new data besides the user in SSR for a page if you set:
"
// some-page.tsx
export const getServerSideProps = getUserFromServerSession({
redirectToLogin: true,
});
"
It wouldn't be a bit tricky?
Hey - sorry for the late reply.
If you want to fetch custom data for a certain route you would just have a custom getServerSideProps for that page. Or you can adjust and rename getUserFromServerSession if you intend to fetch the same data on the server for multiple routes. The above was just one example how to you can refactor and reuse getServerSideProps for a couple of pages.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice article. I was wondering how you could fetch new data besides the user in SSR for a page if you set:
"
// some-page.tsx
export const getServerSideProps = getUserFromServerSession({
redirectToLogin: true,
});
"
It wouldn't be a bit tricky?
Hey - sorry for the late reply.
If you want to fetch custom data for a certain route you would just have a custom
getServerSideProps
for that page. Or you can adjust and renamegetUserFromServerSession
if you intend to fetch the same data on the server for multiple routes. The above was just one example how to you can refactor and reusegetServerSideProps
for a couple of pages.