inertia-admin-tables
Skill0 starsChanged 48 days agoMITView on GitHub
Add pagination to Laravel + Inertia React admin tables with numbered pages, a row count, and a rows-per-page selector (shadcn/ui) that keeps search and filter query strings, backed by a server-side allow-list. Use when building admin or dashboard tables, paginating Inertia pages, adding per-page selectors, or when pagination is missing, loses filters, or a shadcn Select opens with nothing showing.
In this repository11 other files it gives its agents.
- bot-proof-formsSkill
- image-uploadsSkill
- json-ld-structured-dataSkill
- mpesa-stk-pushSkill
- paypal-checkoutSkill
- pre-push-checksSkill
- secrets-scannerSkill
- seo-crawlabilitySkill
- shared-network-rate-limitsSkill
- social-share-previewsSkill
- wordpress-migrationSkill
The file
Files
Admin tables with real pagination (Laravel + Inertia React + shadcn/ui)
Server: ->paginate($this->perPage())->withQueryString(). Client: <DataPagination paginator={posts} label="posts" />. The footer shows:
- "Showing 1–25 of 117 posts". It's always visible, so admins know the table is complete.
- Numbered pages with "…" gaps, from Laravel's own
links. Phones show "Page 2 of 5" instead. - A Rows per page selector (10, 25, 50, 100), shown once there are more than 10 rows.
Install
- Copy from
stubs/, dropping.stub:app/Http/Controllers/Concerns/PaginatesTables.phpresources/js/components/data-pagination.tsxresources/js/types/paginated.tstests/Feature/PaginatesTablesTest.php
- The component needs the shadcn/ui
button,paginationandselectcomponents. If the project doesn't have them yet, add them with the project's existing shadcn setup (components.json), or ask the user to. - In each admin controller:
use App\Http\Controllers\Concerns\PaginatesTables; class PostController extends Controller { use PaginatesTables; public function index(Request $request): Response { return Inertia::render('admin/posts/index', [ 'posts' => Post::query()->latest()->paginate($this->perPage())->withQueryString(), ]); } } - Under each table:
<DataPagination paginator={posts} label="posts" />, typed asposts: Paginated<Post>.
Rules and gotchas
withQueryString()on every paginator. Without it, page links drop?q=and?status=, and page 2 of a search shows unfiltered results.- Allow-list page sizes on the server.
per_page=100000must not dump a whole table.perPage()accepts onlyPER_PAGE_OPTIONSand falls back to 25. Keep the PHP and TSX lists identical. - Changing the page size goes back to page 1. Otherwise page 5 of 10-row pages becomes an empty page of 100-row pages. The component removes
pagefrom the URL. - Selects at the bottom of the page must open upwards. Many shadcn
SelectContentsetups useposition="popper",side="bottom"andavoidCollisions={false}, and cap their height to the space below the trigger. In a table footer that space is close to zero, so the list opens with nothing showing. The component passesside="top" avoidCollisions. - Don't hide the footer when everything fits. "Showing 1–12 of 12" confirms nothing is missing. Only the page links hide on a single page.
- Stale tabs after deploys: Inertia reloads the page when the asset version changes, but only if
HandleInertiaRequests::version()returns the Vite manifest hash (the default). If clicks do nothing after a deploy, check the browser console for "Failed to fetch dynamically imported module". - Big tables:
paginate()runs acount(*)on every page. For millions of rows, usesimplePaginate()orcursorPaginate()and hide the total.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

