Optimize performance for metadata-based integration
If you're using JSS 22.1 or later and you've integrated your JSS Next.js app with SitecoreAI Pages using metadata, you might have decided you no longer want to integrate with Sitecore Experience Editor. If that's the case, we recommend you make some changes to your app to simplify its configuration and improve its performance.
Metadata-based editing is not currently available in preview mode, so only make these optimizations if you don't intend to use your app as an editing host.
To optimize performance for metadata-based integration:
-
In the
lib/next-config/plugins/cors-header.jsplugin, remove the following header (because CORS is now handled by API handlers and middleware): -
Because there is no further need to enforce absolute URLs, your integration no longer needs to use
publicUrl, so we recommend you remove all references to it from your application. Firstly, inlayout.tsx:-
Remove the following, including the associated code comment:
-
Locate the following statement:
-
Replace that statement with the following:
-
-
In
navigation.tsx:-
Remove the following, including the associated code comment:
-
Locate the following statement:
-
Replace that statement with the following:
-
-
In
lib/config.ts, remove the following: -
In
scripts/config/plugins/fallback.ts, remove the following: -
In
next.config.js:-
Remove the following, including the associated code comment:
-
Then remove the following:
-
-
If you're connecting Pages to your local instance, update the
ServerSideRenderingEngineApplicationUrlsetting of the rendering host configuration item in SitecoreAI (/sitecore/system/Settings/Services/Rendering Hosts/Default) to point to the container's external rendering host URL. This URL is typically found in the local container's.envfile. Its default value is normallyRENDERING_HOST=www.nextjs-starter.localhost.