Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Emokores's avatar

Show more than one paginated data object in inertiaJS with React

Is there a way to show more than one paginated table in inertia? Inertia provides a { data } object, and apparently, you can only have one per page. How can I show another table with backend pagination on the same page? I am working with tabs and I need to display a table per tab on the same page.

0 likes
7 replies
Sinnbeck's avatar

Just pass multiple paginated collections to the page. You can have different names for the page number

$publishedArticles = Article::paginate(10, ['*'], 'published');
$unpublishedArticles = Article::paginate(10, ['*'], 'unpublished');

Example code from https://stackoverflow.com/a/39012747

Not sure what data you refer to btw

Emokores's avatar

@Sinnbeck I saw that example code. But, my challenge is I have two models I would like to display. I noticed that everytime I use the code structure below, my data is displayed correctly.


const {users} = usePage().props
const {data} = users     // <--- this will work

const {usersData} = users    // <--- this does not work

When I map() through data the data is displayed correctly and I can access anything about it. However, when I change the destructuring object to another name, it doesn't work.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@Emokores no need to destruct it

const {users} = usePage().props
users.data.map()
Emokores's avatar

@Sinnbeck I didn't know about this! I've been stuck with this for decades. There's another solution just tried out a while ago and it has worked too:

const {users} = usePage().props
const {data: usersData} = users

usersData.map()

I feel I have been set free from a cage. The downside of learning React and Inertia self-taught!

Sinnbeck's avatar

@Emokores it's just object destructuring. Nothing to do with react or inertia :)

Another way is

const usersData = users.data;
1 like

Please or to participate in this conversation.