# <InfiniteScroll />
Infinite Scroll:
-
We can enable infinite scroll in amp pages in 3 ways:
-
1: If
featureConfig > infiniteScroll > source
iscustom
then provide an async custom function forinlineConfig
&remoteConfigEndpoint
infiniteScroll is powered bycustomFunction
response.- The response should be in this format for inline configurations
[ { "image": "https://example.com/image.jpg", "title": "This article shows next", "url": "https://example.com/article.amp.html" }, // ... ]
- The response should be in this format for inline configurations
-
Remote configurations require the server to return a JSON object with the pages key/value pair.
{ pages: [ { "image": "https://example.com/image.jpg", "title": "This article shows next", "url": "https://example.com/article.amp.html" } // ... ] }
-
For more information, please go through
https://amp.dev/documentation/components/amp-next-page/
-
2: If
featureConfig > infiniteScroll > source
isrelatedStoriesApi
- infiniteScroll is powered byrelatedStoriesApi
response. -
3: If
featureConfig > infiniteScroll > source
isnot provided
, there needs to be a collection created with slugamp-infinite-scroll
. The stories from this collection power the infinite scroll. -
Please note that stories behind hard paywall (i.e. which have story.access ===
subscription
) are not shown in infinite scroll. -
Infinite scroll can be disabled by deleting the collection having slug
amp-infinite-scroll
. -
The text for the separator that separates two stories in an infinite scroll can be customized. Pass the text of your choice to
opts.featureConfig.infiniteScroll.storySeparatorText
. -
If you wish to override infinite scroll content, you can do so using the
infiniteScrollRender
render prop. See opts tutorial for more info.