Server API
Contents
Import these functions from @enonic/nextjs-adapter/server. They depend on server-side Next.js and network APIs and must not enter client bundles.
Usage
import {
fetchContent,
fetchContentPathsForAllLocales,
fetchGuillotine
} from '@enonic/nextjs-adapter/server';
Functions
fetchContent
Fetches content metadata and registered component data, builds the page tree, and calculates runtime metadata.
Parameters
fetchContent() takes a single context object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
|
Site-relative content path. |
|
|
|
Optional. Incoming headers. Draft Mode headers are added automatically when enabled. |
|
|
|
Optional. Active route locale; defaults through |
Returns
Promise<FetchContentResult>.
Example
const result = await fetchContent({
locale: 'en',
contentPath: ['news', 'launch']
});
fetchGuillotine
Sends a GraphQL request to Guillotine, minifies the query, and normalizes GraphQL and transport errors into a GuillotineResult.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Guillotine endpoint URL. |
|
|
Optional. Request body, headers, cache, and Next.js revalidation options. |
Returns
Promise<GuillotineResult>.
fetchFromApi
Low-level JSON request used by fetchGuillotine(). It applies JSON headers and throws structured errors for network, HTTP, empty, or non-JSON responses.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Destination URL. |
|
|
Optional. Fetch and Next.js caching options. |
Returns
Promise<GuillotineResponseJson>.
fetchContentPathsForAllLocales
Returns content paths for every configured locale, normally for generateStaticParams().
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Optional. Guillotine query. Defaults to the adapter’s static-path query. |
|
|
|
Optional. Maximum per locale. Default: |
Returns
Promise<ContentPathItem[]>.
fetchContentPathsForLocale
Returns content paths for one LocaleMapping.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
Locale, project, and site to query. |
|
|
|
|
Optional. Guillotine query. |
|
|
|
Optional. Maximum results. Default: |
Returns
Promise<ContentPathItem[]>.
Classes
This entry point exports no classes.
Type Definitions
FetchContentResult
| Name | Type | Description |
|---|---|---|
|
|
|
Content-type query result. |
|
|
|
Shared query result. |
|
|
Runtime and editing context. |
|
|
|
|
Normalized page component tree. |
|
|
|
Optional. Structured failure. |
FetchOptions
Standard RequestInit options with a JSON body containing query and variables, plus Next.js revalidate and tags options.
ContentPathItem
Contains contentPath: string[] and locale: string for one statically generated route.
Constants
This entry point exports no constants. Shared constants are available from the package root.