Hey sorry I didn’t get back to you sooner. I don’t think it’s possible, because with the app dir, layouts don’t have access to any page level data.
i see. is there a way out of this or will this just be a limitation of Plasmic?
What’s the best solution for a global Cart panel from Plasmic?
i see. is there a way out of this or will this just be a limitation of Plasmic?
This is a limitation of app dir, not Plasmic. Previously, pages dir’s app.js was able to read page props, but now it can’t.
What’s the best solution for a global Cart panel from Plasmic?
The good thing about app dir is that now layouts behave just like any other server component. You should be able to fetch your cart data in your layout file and put aPlasmicClientRootProvider
in the layout file. In your page components, you’ll add another, separate root provider. Here’s an example of using a Plasmic component in a layout: https://docs.plasmic.app/learn/nextjs-quickstart/#using-plasmic-components-in-a-shared-layout
got it, great point just have multiple root providers. i’ll give it a whirl thanks
is there any downside to multiple root providers? like Header + Footer + Cart + X
There shouldn’t be. Just remember to use skipCss
on inner root providers. https://docs.plasmic.app/learn/react-api/#plasmicrootprovider-
For me, i have to have skipCss=false on both - otherwise only half works. strange…