Order of execution - generateMetadata and rendering page.tsx
Unanswered
Harrier posted this in #help-forum
HarrierOP
Hello!
Is there a particular order of execution in case of vising a route? Does page.tsx render first? Or is generateMetadata run before rendering?
I've made an experiment with putting console.log in each of them, and order is as follows;
1. page.tsx
2. generateMetadata
Not sure how much I can trust it though.
Is there a particular order of execution in case of vising a route? Does page.tsx render first? Or is generateMetadata run before rendering?
I've made an experiment with putting console.log in each of them, and order is as follows;
1. page.tsx
2. generateMetadata
Not sure how much I can trust it though.
2 Replies
Giant panda
Just don't make any assumptions. As identical requests are memoized there isn't much to worry about here anyways.
@Giant panda Just don't make any assumptions. As identical requests are memoized there isn't much to worry about here anyways.
HarrierOP
I would like to, but I needed that for debugging purposes.
I have a request that needs authentication header, and I was trying to handle a case, where an access token expires and needs to be refreshed. An auth library I use provides an SDK that allows to perform token refresh, but it requires to run on the client side. If session doesn't exists, a resource cannot be fetched, and I cannot generate metadata. That's why the order matters for me
I have a request that needs authentication header, and I was trying to handle a case, where an access token expires and needs to be refreshed. An auth library I use provides an SDK that allows to perform token refresh, but it requires to run on the client side. If session doesn't exists, a resource cannot be fetched, and I cannot generate metadata. That's why the order matters for me