enonic-nextxp-integration
Original:🇺🇸 English
Translated
1 scriptsChecked / no sensitive code detected
Guides setup, development, and troubleshooting of the Next.js and Enonic XP headless integration (Next.XP framework). Covers Enonic adapter configuration, content type to React component mapping, Guillotine GraphQL data fetching, Content Studio preview mode, and draft/master branch switching. Use when building a Next.js frontend powered by Enonic XP, configuring the Next.XP adapter, mapping content types to components, fetching Enonic content via Guillotine in Next.js, or debugging Content Studio preview. Don't use for traditional server-side Enonic XP rendering, standalone Guillotine queries without Next.js, non-Next.js frontend frameworks with Enonic, or React4XP embedded rendering.
6installs
Added on
NPX Install
npx skill4agent add webmaxru/enonic-agent-skills enonic-nextxp-integrationTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Next.js + Enonic XP Headless Integration (Next.XP)
Procedures
Step 1: Identify the workspace integration surface
- Inspect the workspace for Next.js entry points (,
next.config.*withpackage.jsondependency), Enonic XP app markers (nextwithbuild.gradle), or existing Next.XP adapter references (com.enonic.xp).@enonic/nextjs-adapter - Execute to inventory Next.js projects,
node scripts/find-nextxp-targets.mjs .files with.envvariables, component mapping files (ENONIC_*), and Guillotine query files when a Node runtime is available._mappings.ts - If a Node runtime is unavailable, inspect ,
package.json, and.envmanually to identify the integration surface.src/components/_mappings.ts - If the workspace contains both an Enonic XP app and a Next.js frontend, confirm which side the task targets before proceeding.
- If the workspace is not a Next.js + Enonic XP project, stop and explain that this skill does not apply.
Step 2: Configure the Enonic adapter
- Read before writing or modifying configuration.
references/nextxp-reference.md - Verify or create the (or
.envfor local development) file in the Next.js project root with the required variables:.env.local- — shared secret for preview mode authentication.
ENONIC_API_TOKEN - — fully qualified Enonic application name (e.g.,
ENONIC_APP_NAME).com.example.myproject - — locale-to-project/site mapping (e.g.,
ENONIC_MAPPINGS).en:intro/hmdb - — base URL for the Guillotine API endpoint (e.g.,
ENONIC_API).http://127.0.0.1:8080/site
- Install the package if not already present. Use the version matching the Next.js version:
@enonic/nextjs-adapterfor Next.js 16+ ornpm install @enonic/nextjs-adapter@4for Next.js 14.x. Seenpm install @enonic/nextjs-adapter@3for version requirements.references/compatibility.md - Verify the Next.js project was scaffolded from the or contains the expected file structure:
nextxp-template,src/components/_mappings.ts, and API routes undersrc/app/[locale]/[[...contentPath]]/page.tsx.src/app/api/ - Read to confirm version requirements between
references/compatibility.md, Next.js, and Enonic XP.@enonic/nextjs-adapter
Step 3: Map content types to React components
- Read for the component registry API and mapping patterns.
references/nextxp-reference.md - Read for complete content type mapping examples including queries, views, and processors.
references/examples.md - For each Enonic content type that needs a custom rendering:
a. Create a Guillotine GraphQL query function in that fetches the fields specific to that content type using type introspection (
src/components/queries/). b. Create a React view component in... on AppName_ContentTypeNamethat acceptssrc/components/views/props and renders the fetched data. c. Register both inFetchContentResultusingsrc/components/_mappings.ts.ComponentRegistry.addContentType() - For page components (pages, parts, layouts):
a. Define the component XML in the Enonic app under ,
src/main/resources/site/pages/, orparts/. b. Create a corresponding React component inlayouts/,src/components/pages/, orparts/. c. Register usinglayouts/,ComponentRegistry.addPage(), orComponentRegistry.addPart().ComponentRegistry.addLayout() - Use and
APP_NAMEimports fromAPP_NAME_UNDERSCOREDto keep content type references dynamic.@enonic/nextjs-adapter
Step 4: Configure Guillotine data fetching
- Read for the Guillotine query structure and variable passing.
references/nextxp-reference.md - Write GraphQL queries that use as the primary variable for content retrieval via
$path:ID!.guillotine { get(key:$path) { ... } } - Use type introspection to access content-type-specific fields: .
... on AppName_ContentTypeName { data { ... } } - For parts and configurable components, export a query object with and
query(path, context, config)functions.variables(path, context, config) - Use processors (optional async functions) to post-process query results before passing to the view.
- Use for data shared across all page components. Remove the common query if not needed to optimize performance.
ComponentRegistry.setCommonQuery() - Use and
getUrl()helper functions from the adapter for URL handling that works in both standalone and Content Studio preview modes.getAsset()
Step 5: Enable Content Studio preview mode
- Read for full preview architecture details.
references/nextxp-reference.md - Install the app in Enonic XP:
Next.XP.XP Menu → Applications → Install → search "Next.XP" - Add the Next.XP app to the target site in Content Studio via the "Applications" combobox on the site edit view.
- Verify default preview configuration: URL and secret matching
http://127.0.0.1:3000.ENONIC_API_TOKEN - For production, configure the Next.XP app with the deployed Next.js URL and shared secret via app config:
nextjs.default.url = <Next.js app URL> nextjs.default.secret = <shared secret> - Preview mode automatically switches the Guillotine API to the branch, while the public Next.js frontend uses the
draft(published) branch.master - Use in all component links to ensure URLs resolve correctly across preview, inline, and edit modes in Content Studio.
getUrl() - If preview shows a blank page, read for diagnostic steps.
references/troubleshooting.md
Step 6: Deploy to production
- Read for the deployment checklist.
references/nextxp-reference.md - Deploy the Enonic app to Enonic Cloud using .
enonic cloud app install - Create an ingress in Enonic Cloud to expose the Guillotine API (target path , public path
/site)./api - Deploy the Next.js app to Vercel or another hosting platform.
- Set production environment variables: ,
ENONIC_API,ENONIC_APP_NAME,ENONIC_API_TOKEN.ENONIC_MAPPINGS - Configure the Next.XP app in Enonic Cloud to point to the production Next.js URL.
- Publish content in Content Studio to make it visible on the live frontend.
Step 7: Validate the integration
- Execute to confirm the adapter, mappings, and env configuration still resolve correctly.
node scripts/find-nextxp-targets.mjs . - Verify that standalone Next.js rendering works at with published content.
http://localhost:3000 - Verify Content Studio preview renders correctly for both draft and published content.
- Test content type mappings by visiting content URLs and confirming custom views render.
- Run the workspace build () to catch TypeScript or build errors.
npm run build
Error Handling
- If Content Studio preview shows a blank page, read for preview proxy diagnostics, token mismatch detection, and CORS issues.
references/troubleshooting.md - If Guillotine queries return empty or unexpected data, verify the content type name matches the introspection pattern and test the query in GraphQL Playground at .
http://localhost:8080/site/<project> - If imports fail, check
@enonic/nextjs-adapterfor version requirements and confirm the package is installed.references/compatibility.md - If content renders in preview but not on the public site, verify the content is published (moved from to
draftbranch).master - If component mappings are not applied, verify registrations in use the correct fully-qualified content type or component name with
_mappings.ts.APP_NAME