What is a proper approach for keeping initial site config for App Router? #69381
Unanswered
develos-dr
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello everybody!
I have a question about what is a proper approach for loading and keeping the site initial configuration. My project have some config that is fetched from database on side load. This needs to be loaded once and data are immutable. Those are things like white labelling or translations.
I prepared a next API that combines all requests and then i call this api just to get all the data in one call. So we have an AppContext that is used in a root Layout.
Above root layout and below the context provider. Here we load all the data on server type component and as props we initialize layout.
And also AppContextProvider file as well:
BUT i see some weird behavior. So i generate page dynamically. I have some kind of renderer which base on current route path generate page. All works good, so to handle that in main app folder i have [[...slug]]/page.tsx
As you might noticed i have two console logs, one in root layout and one in Page.tsx. The thing is that whenever i change a page i check the logs in Client and in Next itself. As for client it looks good
then for next itself not.
Whenever i change the page on client side i have whole layout generated on "backend" so i got a lot of additional api calls (to my backend C# api) to fulfill the context. Also what is weird for me it looks like it generate layout also for files like /GET /_next/static/chunks/lucide-react.js.map 200 in 1697ms/.
Am i doing it wrong? What is a proper approach for such things in app router. I can understand that we need to generate everything for first request but is there a way to somehow share user context from client side? Why we need to load it even for resources files?
Beta Was this translation helpful? Give feedback.
All reactions