Skip to main content

Next.js

info

We have a guide explaining how to integrate Composer Core with Next.js: Next.js CX Framework Guide

getServerSidePropsFactory(fetcher)

Returns a getServerSideProps-compatible method.

ParameterTypeDefaultRequired?Description
fetcherFetcher-YesAn instance of a fetcher.
slugstring-NoOptional slug (page path) if you want to request experience data for a specific page only.

getStaticPropsFactory(fetcher)

Returns a getStaticProps-compatible method.

ParameterTypeDefaultRequired?Description
fetcherFetcher-YesAn instance of a fetcher.
revalidatenumber60NoThe revalidation timeout. See Incremental Static Regeneration for details.
prefixstring-NoA prefix to use for all routes.
slugstring-NoOptional slug (page path) if you want to request experience data for a specific page only.

getStaticPathsFactory(fetcher)

Returns a getStaticPaths-compatible method.

ParameterTypeDefaultRequired?Description
fetcherFetcher-YesAn instance of a fetcher.
configobject{
 excludedPaths:
  [
   '/',
   '404'
  ]
}
NoBy default, the homepage as well as the 404 page are excluded from being statically generated because within Next.js ideally you have a index.tsx and a 404.tsx route.

The config object accepts any parameter from the fetcher#getAllPaths method.

createActionHandler(fetcher)

Returns an API Route-compatible method.

ParameterTypeDefaultRequired?Description
fetcherFetcher-YesAn instance of a fetcher.

action(actionConfig)

Returns a method that can be executed to run the action. Use with a library like @tanstack/react-query or swr.

ParameterTypeDefaultRequired?Description
actionIdstring-YesThe id of the action to run
slugstring-YesThe slug of the page the action is run on
apiRoutePathstring/api/actions/NoThe path to run the action against

The returned method accepts an object adhering to the action business capabilities request schema.