# Pagination on Custom types

**URL:** <https://community.prismic.io/t/pagination-on-custom-types/14540>\
**Category:** Developing with Prismic\
**Tags:** svelte, javascript\
**Created:** [November 17, 2023, 10:37am UTC](https://community.prismic.io/t/pagination-on-custom-types/14540 "2023-11-17T10:37:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![frontend2](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/frontend2/32/6584_2.png) [@frontend2](https://community.prismic.io/u/frontend2)\
**Post date:** [November 17, 2023, 10:37am UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/1 "2023-11-17T10:37:46Z")

</div>

I'm trying to create pagination on custom types, trying to set limitations but I see that it limits not exactly my articles, here I add screenshots of my custom type and the data structure that I get from prismic

 ![Screenshot 2023-11-17 at 11.33.46](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/9/99b2bc6bc306482ebedcad66806535b881f27b0f.png)  
 ![Screenshot 2023-11-17 at 11.35.03](https://europe1.discourse-cdn.com/flex013/uploads/prismic/original/2X/c/cca1b8484725a78bdc151514905bd10713ea3933.png)

and here you can see how I fetch data with prismic client  
`const res = await client.getAllByType('articles', {limit:2})`

I do not really understand how to limit the count of articles from data

Thank you

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [November 22, 2023, 3:33pm UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/3 "2023-11-22T15:33:13Z")

</div>

Hi Jakub,

It sounds like the API option you want might be `pageSize`, rather than `limit`. To the best of my knowledge, we don't have a `limit` option.

See the `pageSize` option, here:

> **[Document API Technical Reference](https://prismic.io/docs/rest-api-technical-reference#pagesize)**
>
> The Prismic Document API is an extremely fast, flexible, and powerful engine for your content. This page provides definitions for all of the API parameters.

You could try this:

```js
const res = await client.getAllByType('articles', {pageSize:2})

```

Let me know if that helps.  
Sam

---

<div class="post-metadata">

**Author:** ![nf\_mastroianni](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/nf_mastroianni/32/7071_2.png) [@nf\_mastroianni](https://community.prismic.io/u/nf_mastroianni)\
**Post date:** [November 22, 2023, 7:51pm UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/5 "2023-11-22T19:51:06Z")

</div>

If I may be so bold as to interject...

I believe the "get all" methods like getAllByType do not return a paginated list where the standard methods do like getByType. See an example I use for my blog index:  
[Documentation](https://prismic.io/docs/technical-reference/prismicio-client#query-methods)  
I've included all but my structured data in case it helps:

```auto
import { Metadata } from 'next'
import { notFound } from 'next/navigation'
import { SliceZone } from '@prismicio/react'
import * as prismic from '@prismicio/client'
import { createClient } from '@/prismicio'
import { components } from '@/slices'
import { Graph } from 'schema-dts'
import Section from '@/components/Section'
import BlogCard from '@/components/BlogCard'
import Pagination from '@/components/Pagination'
export default async function Page({
  params,
  searchParams,
}: {
  params: Params
  searchParams: SearchParams
}) {
  const client = createClient()
  const pageNumber = Number(searchParams['page']) || 1
  const page = await client.getByUID('page', params.uid).catch(() => notFound())
  let posts
  if (page.uid === 'blog') {
    posts = await client.getByType('post', {
      orderings: {
        field: 'document.first_publication_date',
        direction: 'desc',
      },
      page: pageNumber,
      pageSize: 5,
    })
  }
  const settings = await client.getSingle('settings')
return (
    <>
      <script
        type="application/ld+json"
        dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }}
      />
      <SliceZone slices={page.data.slices} components={components} />
      {/* CODE FOR BLOG PAGE ONLY */}
      {page.uid === 'blog' && (
        <Section width="md">
          {posts && posts.results.length > 0 ? (
            <ul className="px-4 lg:px-0">
              {posts.results.map(post => {
                return (
                  <BlogCard
                    key={post.id}
                    post={post}
                    className="mx-auto max-w-xl"
                  />
                )
              })}
            </ul>
          ) : (
            <p className="prose mx-auto lg:prose-lg xl:prose-xl">
              No posts have been published yet. Please check back again soon!
            </p>
          )}
          {(posts?.next_page !== null || posts?.prev_page !== null) && (
            <Pagination
              hasNextPage={posts?.next_page !== null}
              hasPrevPage={posts?.prev_page !== null}
              totalPages={Number(posts?.total_pages)}
            />
          )}
        </Section>
      )}
      {/* END BLOG PAGE CODE */}
    </>
  )
}

```

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [November 23, 2023, 3:33pm UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/7 "2023-11-23T15:33:23Z")

</div>

@nf_mastroianni You're completely correct! In this case, neither `pageSize` nor `limit` should have any effect whatsoever.

---

<div class="post-metadata">

**Author:** ![kehindephilip15](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/kehindephilip15/32/8432_2.png) [@kehindephilip15](https://community.prismic.io/u/kehindephilip15)\
**Post date:** [March 14, 2024, 2:43pm UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/9 "2024-03-14T14:43:10Z")

</div>

Hello  
Just thought of this, is there a way i can implement something like an infinite loading of more post on click of a button, 10 posts is going to be added to the list when you load more post

Thanks

---

<div class="post-metadata">

**Author:** ![samlittlefair](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/samlittlefair/32/696_2.png) [@samlittlefair](https://community.prismic.io/u/samlittlefair)\
**Post date:** [March 19, 2024, 12:09am UTC](https://community.prismic.io/t/pagination-on-custom-types/14540/11 "2024-03-19T00:09:51Z")

</div>

Hey Omopariola,

This is definitely possible! What stack are you using? I'll try to write up a minimal implementation for you.

Sam
