{
  "id": 263660,
  "title": "Filtering, and Pagination in Next.js 15 The Pattern I Actually Use",
  "url": "https://urgent.news/2026/08/07/filtering-and-pagination-in-next-js-15-the-pattern-i-actually-use",
  "topic": "world",
  "section": "World",
  "published": "2026-08-07T12:16:51.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/anas_sheikh_2/filtering-and-pagination-in-nextjs-15-the-pattern-i-actually-use-57jk"
  },
  "original_language": "en",
  "account": "Every dashboard eventually requires three essential components: a search box, filters, and pagination as the list grows in length. Previously, I implemented this structure using the useState hook, which presented two significant drawbacks. Firstly, any changes to the state would be lost upon page refresh or when sharing a link with others. Secondly, the state could not be bookmarked or shared via URL, making it impossible for users to access a consistent view. To address these issues, I decided to store all these elements in the URL instead. This approach guarantees that a page refresh maintains the current state, shared links display the identical filtered results, and the browser's back button functions as anticipated.\n\nThe solution hinges on utilizing URL search parameters rather than useState state. A URL like /dashboard/orders?search=invoice&status=pending&page=2 encapsulates the entire current view, eliminating the need for client-side state reconstruction.\n\nNext.js's Server Component architecture is employed to fetch and render the data in response to the current URL. In the OrdersPage component, the searchParams prop is utilized to obtain the search query, status, and page number from the URL. The currentPage variable is assigned the page number from the URL or defaulted to 1 if not found. The getOrders function is then called with the search, status, and currentPage parameters to retrieve the relevant orders. The retrieved orders, the total number of pages, and the current page number are then returned to render the appropriate UI components.\n\nSimultaneously, the OrderFilters component, which is a Client Component, updates the URL whenever the user interacts with the filter inputs. It utilizes useRouter, useSearchParams, and usePathname hooks to access the router, search parameters, and current pathname. The OrderFilters component updates the searchParams in response to user input, and the OrdersPage component listens for these changes to update the displayed data accordingly.",
  "summary": "Every dashboard eventually needs the same three things. A search box, a few filters, and pagination once the list gets long. The version I used to build kept all of that in useState , which meant losing your filters the moment you refreshed the page or shared a link with someone else. Keeping this state in the URL instead fixed both problems at once. Here is the setup. 1. Why URL Search Params,…",
  "key_points": [
    "Stores filters and pagination in URL for consistent state across page refreshes and shared links",
    "Utilizes Next.js Server Component architecture to fetch and render data based on URL parameters"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}