Next.js Discord

Discord Forum

Data from database in layout is necessary

Answered
MarkMiklos posted this in #help-forum
Open in Discord
A need some data from the database in the layout for my ThemeProvider, I heard that having a fetch in the layout could be harmful.

I don't have any sensitive data in that request, because it does only contains tenant website informations

Is it okay to do that fetch in the layout, or what could be a possible solution?
Answered by B33fb0n3
yea, you can fetch data in your layout. However: keep in mind, that the layout won't refetch the data in some cases
View full answer

4 Replies

Answer
what are the exact cases that data is not refetched? I need some colors and theme settings tho so It shouldn't be a problem
@MarkMiklos what are the exact cases that data is not refetched? I need some colors and theme settings tho so It shouldn't be a problem
one example is when you navigate on your page, you layout wont get rerendered and like that the data not refetched