Next.js Discord

Discord Forum

How to share data across pages

Unanswered
Bengal posted this in #help-forum
Open in Discord
BengalOP
How would I go about sharing data between pages? I have two routes that need the same data, I do not want to fetch that data twice when switching pages

5 Replies

is this data the same for every user? you could just cache it (it is the default behavior of fetch)
BengalOP
@Rafael Almeida I am fetching from external api, to be specific I am using supabase.
It is not the same for every user, it is only for 'Admin' users and for every admin user it is the same
Great Auk
useContext
BengalOP
@Great Auk I made some layout changes and now it is all under one route. I have one more question, how would refresh the data I get from server component after mutating that data client side?