Json Table

This module wraps the Paginated Table module with a component that fetches data from the given URL and expects the response to be in the same format as Laravel's paginator json output.

Installation

pnpm dlx shadcn@latest add https://astrify.com/r/json-table.json

Usage

This usage example loads data via JSON fetch requests. To load data via Inertia requests see the Paginated Table Module.

resources/js/pages/json-table-example.tsx
routes/web.php

Optionally seed your database with test data to see the pagination in action:

artisan tinker
\App\Models\User::factory(100)->create();

Props

JsonTable

PropTypeDescription
urlstringThe endpoint URL to fetch paginated data from
columnsJsonTableColumn[]Array of column definitions with key and label properties
paginationType"simple" | "numeric" (optional)The pagination style to use (defaults to "numeric")
formatCell(key: string, value: any) => string | number (optional)Optional function to format cell values before display

JsonTableColumn

PropTypeDescription
keystringThe key in the data object to display
labelstringThe column header label