Hi everyone,
I’m integrating Magnolia CMS with a Next.js app and ran into an issue regarding page size.
Context:
I'm using @magnolia/react-editor within a Next.js project to allow marketers to use frontend components in Magnolia pages and place them flexibly. The page content is fetched on the server side using the Magnolia Delivery API.
Problem:
After setting this up, I noticed a significant increase in the size of the page HTML. Upon debugging, I found that the entire page JSON is being sent down in an inline script tag within the HTML.
The confusing part is:
My HOC component that wraps Magnolia rendering logic is a React Server Component, so I wouldn't expect any client-side serialization of the entire JSON.
Questions:
Environment:
Happy to provide more code or repo if it helps. Any insights would be hugely appreciated!
Attached the inline JSON example and HOC logic.
Thanks in advance,
Dhyey
__NEXT_DATA__
--
You received this message because you are subscribed to the Google Groups "Magnolia User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to user-list+...@magnolia-cms.com.
To view this discussion, visit https://groups.google.com/a/magnolia-cms.com/d/msgid/user-list/8b42ca93-e71b-4f48-a71e-f0b0c7890619n%40magnolia-cms.com.
Thank you so much for taking the time to help me out—I really appreciate it.
I'd like to highlight a few observations that might clarify the issue further:
While I do have a few individual client components, they are located deeper in the render tree. I understand and accept that any props passed to those client components would need to be serialised to the client.
However, the root component in my application—the HOC wrapping the Magnolia rendering logic—is a React Server Component. Based on this setup, I would not expect the entire Magnolia page JSON to be serialised and sent to the client.
My intent is to keep the root as a server component, within which I mount Magnolia’s EditablePage component and pass it the complete page JSON along with other configuration options.
After inspecting the @magnolia/react-editor package, I looked into the file: "react-editor/src/server/components/EditablePage/EditablePage.tsx".
From what I can tell, this file mounts the EditablePageClient component, which is a client component. As a result, the entire Magnolia page JSON gets passed down to a client component—explaining why it’s being serialised into the HTML.
Is there any option to opt out of using the page client component, so that the Magnolia page rendering can remain within the server component boundary? This design forces me to mount a client component at the root of the render tree, which prevents me from taking full advantage of React Server Components.
Attaching few screenshots of @magnolia/react-editor package, to which I am referring.
If anyone has found a solution or a pattern to work around this, I’d be very grateful for your input.
Thanks again!
Dhyey
Thanks for the suggestions!
a) Yes, I’ve tried using the nextjs-starter demo project. Unfortunately, the issue originates from the @magnolia/react-editor package itself, so the demo project also exhibits the same behavior.
b) I actually started with version 1.x and later upgraded to 2.0.0, but the issue persists across both versions.
d) I’ve identified the root cause and have opened a detailed request on the official @magnolia/react-editor GitLab repository under the Issues tab.
Appreciate your help, and looking forward to hearing if you're able to reproduce it next week!