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.
Parameter | Type | Default | Required? | Description |
---|---|---|---|---|
fetcher | Fetcher | - | Yes | An instance of a fetcher. |
slug | string | - | No | Optional slug (page path) if you want to request experience data for a specific page only. |
getStaticPropsFactory(fetcher)
Returns a getStaticProps
-compatible method.
Parameter | Type | Default | Required? | Description |
---|---|---|---|---|
fetcher | Fetcher | - | Yes | An instance of a fetcher. |
revalidate | number | 60 | No | The revalidation timeout. See Incremental Static Regeneration for details. |
prefix | string | - | No | A prefix to use for all routes. |
slug | string | - | No | Optional slug (page path) if you want to request experience data for a specific page only. |
getStaticPathsFactory(fetcher)
Returns a getStaticPaths
-compatible method.
Parameter | Type | Default | Required? | Description |
---|---|---|---|---|
fetcher | Fetcher | - | Yes | An instance of a fetcher. |
config | object | { | No | By 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.
Parameter | Type | Default | Required? | Description |
---|---|---|---|---|
fetcher | Fetcher | - | Yes | An 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.
Parameter | Type | Default | Required? | Description |
---|---|---|---|---|
actionId | string | - | Yes | The id of the action to run |
slug | string | - | Yes | The slug of the page the action is run on |
apiRoutePath | string | /api/actions/ | No | The path to run the action against |
The returned method accepts an object adhering to the action business capabilities request schema.