published fresh until

Next.js: how do I add URL filters and infinite scroll to search?

Summary When a Next.js search page needs URL-persistent filters and infinite scrolling, combine URL filters, cursor pagination, a server-side table, and loading states; restoring scroll position on Back has no tested answer.

Not for a records table with export, see case-expense-table-nextjs-supabase-filters-sort-csv-export

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The case

You have a page that lists things (products, listings, posts) with filters such as category, price or search text, and the list keeps loading more results as the user scrolls. Success looks like: filters and sort live in the URL so a refresh, the Back button and a copied link all show the same results, new results load without a jump or duplicates, and the page shows a loading state while filters change. Stack: Next.js (App Router).

This is a map, not new advice: every row points to an existing WhatWorks thread. Nobody here ran this whole build; the Status column says what each linked thread rests on. "Tried" would need a linked trial report, and none of the linked threads has one yet.

Parts, in the order people do them

PartWhat to useStatusLink
Filters, sort and page in the URLsearchParams prop on the page, useSearchParams or nuqs in client controls, SuspenseDocumented: vendor or primary source, not tried (no linked trial)How do I keep my Next.js list filters in the URL?
Infinite scroll or Load moreuseInfiniteQuery with a cursorDocumented: vendor or primary source, not tried (no linked trial)How do I add infinite scroll or Load more to a React list?
Pagination behind the listCursor (keyset) versus offsetDocumented: vendor or primary source, not tried (no linked trial)Cursor or offset pagination for my list endpoint: which one?
Server-side filtering and sorting in a tabletablecn starter (shadcn and TanStack)Documented: vendor or primary source, not tried (no linked trial)Which data table starter handles server-side filters and sorting?
Look while filters refetchKeep old rows, show a pending stateUntried: community post or suggestion only, no linked trialHow should a data table look while it refetches new filters?
Loading and error screensloading.js, error boundaries, skeletonsDocumented: vendor or primary source, not tried (no linked trial)How do I add loading skeletons and error pages in Next.js?
Restore scroll position on Back for a long listNo tested answer yetNo tested answer yetnone (see open request)

Where it breaks

Open questions

  • Parts marked "No tested answer yet" are gaps in WhatWorks; ask for them with the request tool so an editor can look: restoring scroll position after Back on a long list.

Status key

Documented means the linked thread cites official docs or a vendor source and was not run. Untried means the linked thread rests on a community post or on suggestions and was not run. Tried would need a linked trial report, and none exists yet.

As of October 2026. a records table with export, see case-expense-table-nextjs-supabase-filters-sort-csv-export; KPI cards and charts, see case-kpi-dashboard-charts-postgres-scheduled-refresh.

Started from a post by @WhatWorks editors, packaged by the editor.

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Next.js: how do I add URL filters and infinite scroll to search?
Summary: When a Next.js search page needs URL-persistent filters and infinite scrolling, combine URL filters, cursor pagination, a server-side table, and loading states; restoring scroll position on Back has no tested answer.
Copy for agent
get the whatworks thread case-search-page-url-filters-infinite-scroll-nextjs and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread case-search-page-url-filters-infinite-scroll-nextjs
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks