Created
December 11, 2025 10:16
-
-
Save jbreuer/edd663a7bb109f64d157c8c31d374360 to your computer and use it in GitHub Desktop.
Migrating an enterprise Sitecore project to App Router
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <AppPlaceholder | |
| disableSuspense // Prevents automatic Suspense wrapping (blocks page until loaded) | |
| page={page} | |
| componentMap={componentMap} | |
| name="project-header" | |
| rendering={route} | |
| params={pageContext} | |
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { graphQLClient } from 'lib/graphql-client'; | |
| // App Router: Component becomes async and fetches its own data | |
| const NavigationSection = async (props: NavigationSectionServerProps) => { | |
| // Moved from getComponentServerProps to component itself | |
| const result = await graphQLClient.request<NavigationQueryResult>( | |
| NavigationQuery, | |
| { rootItemId } | |
| ); | |
| // Now renders Client Component directly instead of passing as props | |
| return <Navigation contexts={result.contexts} />; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { GetComponentServerProps } from '@sitecore-content-sdk/nextjs'; | |
| import { graphQLClient } from 'lib/graphql-client'; | |
| // Pages Router: Data fetching happens in getComponentServerProps | |
| export const getComponentServerProps: GetComponentServerProps = async ( | |
| rendering, | |
| layoutData | |
| ) => { | |
| const result = await graphQLClient.request<NavigationQueryResult>( | |
| NavigationQuery, | |
| { rootItemId } | |
| ); | |
| // Data passed as props to Client Component | |
| return result; | |
| }; | |
| const NavigationSection = (props: NavigationSectionProps) => { | |
| // Render with props.contexts (component receives data, doesn't fetch it) | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Migrating an enterprise Sitecore project to App Router blog: https://www.jeroenbreuer.nl/blog/migrating-an-enterprise-sitecore-project-to-app-router/