# Connect Data offset for paging

**URL:** <https://forum.builder.io/t/connect-data-offset-for-paging/4078>\
**Category:** CMS\
**Created:** [August 17, 2023, 5:17am UTC](https://forum.builder.io/t/connect-data-offset-for-paging/4078 "2023-08-17T05:17:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kayakyakr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/kayakyakr/32/2817_2.png) [@kayakyakr](https://forum.builder.io/u/kayakyakr)\
**Post date:** [August 17, 2023, 5:17am UTC](https://forum.builder.io/t/connect-data-offset-for-paging/4078/1 "2023-08-17T05:17:55Z")

</div>

I’m playing around with the concept of a no-code, paged list. I have it pulling in data just fine, but that gets me the first “x” results. I want to append a query string and pull the next page’s data.

I’m not seeing a way to add an offset to the connected data in the visual CMS. I’d like to bind that to a query parameter or something so I can get page 2, 3, and so on. Is this supported, and if not, anyone see a hack to add it in?

---

<div class="post-metadata">

**Author:** ![OmPrakash](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/omprakash/32/2751_2.png) [@OmPrakash](https://forum.builder.io/u/OmPrakash)\
**Post date:** [August 17, 2023, 6:10pm UTC](https://forum.builder.io/t/connect-data-offset-for-paging/4078/2 "2023-08-17T18:10:00Z")

</div>

Welcome, @kayakyakr, to the forum community!

I think you could use query params like _offset, limit etc_ for pagination.

Please take a look at the below Content API, I think that can help.

> **[Builder.io Content API - Builder.io](https://www.builder.io/c/docs/content-api#code-offset-code)**
>
> Drag and drop with your components, right within your existing site or app. Build and optimize digital experiences for any tech stack, visually.

For more detailed information, you can refer to these resources:

- **Using Custom Code:** [Custom Code Guide](https://www.builder.io/c/docs/guides/custom-code)
- **Querying:** [Querying Guide](https://www.builder.io/c/docs/querying)

Here’s a sample code that demonstrates how you can generate static paths for pagination:

```auto
export async function getStaticPaths() {
  const limit = 100;
  let offset = 0;
  const pages = await builder.getAll('page', {
    options: { noTargeting: true },
    fields: 'data.url',
  })

  while(pages.length === (limit + offset)) {
    offset += limit;
    pages.push(...(await builder.getAll('page', {
      options: { noTargeting: true },
      fields: 'data.url',
      offset, 
      limit
    })))
  }

  return {
    paths: pages.map((page) => `${page.data?.url}`),
    fallback: true,
  }
}

```

I hope that helps, feel free to let us know how that goes.

---

<div class="post-metadata">

**Author:** ![kayakyakr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/kayakyakr/32/2817_2.png) [@kayakyakr](https://forum.builder.io/u/kayakyakr)\
**Post date:** [August 17, 2023, 9:15pm UTC](https://forum.builder.io/t/connect-data-offset-for-paging/4078/3 "2023-08-17T21:15:25Z")

</div>

Yes, I could do that within my codebase, but I’m trying to use the visual CMS’s built-in data connectors, binders, and the repeater.

I was thinking about adding a fetch to the scripts (within the builder page) that adds the results to the state. Bindings should be able to then pull those values for components. That’s the theory, at least. Is there something there?

I could do a pagination wrapper custom component, but I’m not sure if I’d be able to use the data that I pull into that component to create a repeating, bound subsection.

---

<div class="post-metadata">

**Author:** ![OmPrakash](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/omprakash/32/2751_2.png) [@OmPrakash](https://forum.builder.io/u/OmPrakash)\
**Post date:** [August 18, 2023, 3:10am UTC](https://forum.builder.io/t/connect-data-offset-for-paging/4078/4 "2023-08-18T03:10:00Z")

</div>

Hi @kayakyakr,

You can utilize state bindings within your components. For detailed instructions, refer to the documentation [here](https://www.builder.io/c/docs/custom-components-setup#programmatically-setting-bindings).

When working with the provided data connectors, you’ll find an option to access the query tab. This allows you to set limits and implement custom queries.

 ![Screenshot 2023-08-18 at 8.36.06 AM](https://us1.discourse-cdn.com/flex020/uploads/builder/original/2X/e/ea705408eca2bd975e3e7af99c2a056b4bb7020a.png)

For a deeper grasp on querying within the visual editor, check out this informative post [here](https://forum.builder.io/t/creating-blog-feed-page-using-visual-editor/4030/4).

Give these approaches a try and feel free to share your results with us. Your feedback is valuable!
