Frontend SDK - v1 vs v2 examples
This page documents the breaking changes between Magnolia Frontend SDK v1 and v2, with parallel code examples for Angular, React, and Vue frameworks.
Migration checklist
Key steps to migrate from v1 to v2
-
Update Package Imports
Replace wrapper imports with direct imports from
@magnolia/frontend-helpers-base. -
Remove iframe-based Detection
Replace
inIframe(),inEditor(),inEditorAsync()withEditorContextService.getMagnoliaContext(). -
Update EditablePage Properties
Remove:
templateDefinitions.Add:
magnoliaContext, passconfigandtemplateAnnotationsas props. -
Rewrite Extended Components (React only)
Convert class-based extensions to functional wrapper components.
-
Update TypeScript Declarations
Add proper type annotations using new TypeScript types.
-
Test EditableArea Custom Views
Verify custom rendering works with new children processing.
-
Update Configuration Files
Add TypeScript types to config files if using TypeScript.
-
Test SSR/Personalization
Verify server-side rendering works on both author and public instances.
Package installation & imports
The EditorContextHelper and PersonalizationService wrappers have been removed.
All functions must be imported directly from @magnolia/frontend-helpers-base.
| v1 (Old Approach) | v2 (New Approach) |
|---|---|
|
|
| v1 (Old Approach) | v2 (New Approach) |
|---|---|
|
|
| v1 (Old Approach) | v2 (New Approach) |
|---|---|
|
|
Editor context detection
The new magnoliaContext object standardizes usage across all frameworks and determines page mode (edit/preview) instead of iframe-based detection methods like inEditor or inEditorAsync.
| v1 (Iframe-based Detection) | v2 (magnoliaContext Object) |
|---|---|
|
|
| v1 (Iframe-based Detection) | v2 (magnoliaContext Object) |
|---|---|
|
|
| v1 (Iframe-based Detection) | v2 (magnoliaContext Object) |
|---|---|
|
|
EditablePage component configuration
-
Removed:
templateDefinitionsproperty. -
Removed:
EditorContextServicemethods fortemplateAnnotationsandconfig. -
Added:
magnoliaContextproperty (required). -
Added:
configproperty passed directly to component. -
Added:
templateAnnotationsproperty passed directly to component.
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
EditableArea component
-
Angular: Now supports both tag and directive syntax.
-
Angular:
editable-areacan have additional children besidescontentandcustomView. -
React: Updated children processing logic.
| v1 (Configuration) | v2 (Enhanced Support) |
|---|---|
|
|
| v1 (Configuration) | v2 (Enhanced Support) |
|---|---|
|
|
| v1 (Configuration) | v2 (Enhanced Support) |
|---|---|
|
|
Component types and extensibility (React Only)
-
EditablePage,EditableArea, andEditableComponentare now functional components. -
Cannot extend these components using class inheritance.
-
Custom components must be rewritten as wrapper components or composition patterns.
| v1 (Class-based) | v2 (Functional) |
|---|---|
|
|
Configuration files
-
Configuration structure remains the same.
-
TypeScript support added with
MagnoliaConfigtype. -
Component mapping syntax unchanged.
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
| v1 (Configuration) | v2 (Configuration) |
|---|---|
|
|
TypeScript support
| v1 (Limited TypeScript) | v2 (Full TypeScript) |
|---|---|
|
|
| v1 (Limited TypeScript) | v2 (Full TypeScript) |
|---|---|
|
|
null; templateAnnotations: MgnlTemplateAnnotations |
null; } function App(): JSX.Element { const [content, setContent] = useState<MgnlContent |
null>(null); const [templateAnnotations, setTemplateAnnotations] = useState<MgnlTemplateAnnotations |
null>(null); const magnoliaContext: IMagnoliaContext = EditorContextService.getMagnoliaContext(); return ( <EditablePage content={content} templateAnnotations={templateAnnotations} magnoliaContext={magnoliaContext} config={config} /> ); } ---- |
| v1 (Limited TypeScript) | v2 (Full TypeScript) |
|---|---|
|
|
null, templateAnnotations: null as MgnlTemplateAnnotations |
null, magnoliaContext: EditorContextService.getMagnoliaContext() as IMagnoliaContext, config: config as MagnoliaConfig } } } ---- |
Server-side rendering (SSR) and personalization
Full SSR support in v2:
-
Server-Side Rendering enabled for both author and public instances.
-
Author instance supports SSR of personalized content.
-
Improved performance and SEO.
-
Better support for meta-frameworks (Next.js, Nuxt, etc.).
| v1 (No SSR awareness) | v2 (Supports SSR) |
|---|---|
|
|
| v1 (No SSR awareness) | v2 (Supports SSR) |
|---|---|
|
|
| v1 (No SSR awareness) | v2 (Supports SSR) |
|---|---|
|
|