# Supabase Postgress Function Search Pagination

**URL:** <https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053>\
**Category:** Tutorials\
**Tags:** supabase\
**Created:** [September 25, 2025, 7:25pm UTC](https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053 "2025-09-25T19:25:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [September 25, 2025, 7:25pm UTC](https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053/1 "2025-09-25T19:25:47Z")

</div>

Hi guys,

I have a Postgress function that I am calling from WeWeb. I would like to add the pagination, but can’t really figure it out.

These are my param:

 ![Screenshot 2025-09-25 at 22.21.46](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/8465b7c3ab4eb8a3b725afeca3c6419738a4a6e8.png)

I get this back:

 ![Screenshot 2025-09-25 at 22.23.00](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/0d83af3c39ba15edf6c5d1f00b7648311566e5eb.png)

In the Custom Paginator, I liked the total records called, but not sure if I need to bind the offset here or bind it in the new function call on change.

Thanks,

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [September 26, 2025, 6:53am UTC](https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053/2 "2025-09-26T06:53:54Z")

</div>

If you are passing the offset, then you need to bind it to be `result_limit * (current_page - 1)` if the pages start from 1. I’d probably just change your function to accept `result_limit` and `page` and then do this math on the backend for a cleaner workflow. I also thin you’ll need to return the current page and total\_count, as you’re already doing.

---

<div class="post-metadata">

**Author:** ![Yaj](https://avatars.discourse-cdn.com/v4/letter/y/eb8c5e/32.png) [@Yaj](https://community.weweb.io/u/Yaj)\
**Post date:** [September 29, 2025, 10:56pm UTC](https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053/3 "2025-09-29T22:56:25Z")

</div>

The way I’ve done pagination in Postgres Functions are like what Broberto has said. You want to have the parameters as Page Number and Page Size (result\_limit in your case), then you can do the equation that Broberto said in your function, result\_limit \* (current\_page - 1).

Definitely don’t have to return the current page if you don’t want and keep that logic on the front end but that does add extra stuff to the front end, but this also depends on what kind of UI/UX you want for your pagination. I’ve created a global formula to will an array of Pages with “Page ” which takes the total count of the results and the current result limit to give me an array to use for selecting a certain page if thats the kind of UX you want.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/2d97560ff3a162c996e6539bbef4f0a4a3dce843.png)

---

<div class="post-metadata">

**Author:** ![emdiemeric](https://avatars.discourse-cdn.com/v4/letter/e/e9bcb4/32.png) [@emdiemeric](https://community.weweb.io/u/emdiemeric)\
**Post date:** [September 30, 2025, 6:52am UTC](https://community.weweb.io/t/supabase-postgress-function-search-pagination/20053/4 "2025-09-30T06:52:11Z")

</div>

I think I did something similar. It is working now.
