How to render page content in a layout?
Unanswered
Lionhead posted this in #help-forum
LionheadOP
I need to add content, specific to the current page, into a layout. Think header similar to vercel.com where the user can select an organization and project / like a supercharged breadcrumb.
I was considering using parallel routes for that, but unfortunately because they can't resolve state on hard refresh that's a no go. Any ideas besides using multiple layouts further down the component tree?
I was considering using parallel routes for that, but unfortunately because they can't resolve state on hard refresh that's a no go. Any ideas besides using multiple layouts further down the component tree?
5 Replies
Cuvier’s Dwarf Caiman
In an app i'm working on, I used the Context API to achieve this.
I wrapped my layout components (and in turn the child pages) in a Context Provider and set state from wherever I need to.
LionheadOP
Thanks. I am focused on SSR as much as possible, otherwise that would be a great solution for me.
LionheadOP
For now I am settling with top level route groups - which has the benefit of making the folder structure a bit more readable too. Seems like a good enought tradeoff
Cuvier’s Dwarf Caiman
Ah, dang. Yeah, i'm not sure how to achieve this outside of client side state, but i'm still early in my NextJS journey. I'll keep a lookout for a possible solution.