Next.js-based JSS application does not work when SXA is installed


Description

Sitecore Experience Accelerator (SXA) installation might prevent Next.js-based JavaScript Services (JSS) applications from starting. The root cause of the issue is that regular Next.js app and Next.js app items, deployed into JSS tenant, refer to different templates.

The issue affects Sitecore Headless Rendering 18.0.0.

Solution

To resolve the issue, override the default template that is used for finding the app root for both dictionary service (samples\nextjs\src\lib\dictionary-service-factory.ts) and sitemap fetcher (samples\src\lib\sitemap-fetcher.ts):