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

aghead's avatar
Level 31

: Best Practice for Infinite Scroll in Inertia + Vue 3 When User Lands Directly on Page 2+

Hey everyone ๐Ÿ‘‹

I'm implementing infinite scroll in a Laravel 11 + Inertia.js + Vue 3 (script setup) app, and I've hit a design question around handling direct access to a deeper page (e.g., user lands directly on ?page=3).

๐Ÿ” The Problem: When a user lands directly on something like:


/posts?page=3

...I only get the items from page 3 in my props. But for infinite scroll UX, Iโ€™d ideally show:

All items from page 1 up to page 3 as if the user had scrolled down there naturally.

Loading just page 3 feels jarring because it breaks the illusion of continuity in infinite scroll.

๐Ÿค” Possible Solutions I'm Exploring:

1- Fetch all pages up to current via controller and pass as merged prop array

  • This makes the scroll feel "natural"

  • But it loads a lot of data upfront and may be slow for deep links (e.g., ?page=8)

2- Lazy fetch previous pages in Vue

  • When page > 1, load current page first, then fetch previous pages one by one in reverse

  • Allows immediate content + progressive hydration

  • But introduces complexity and async race conditions

3- Prefill placeholders for previous pages and backfill

  • Render dummy cards or skeletons for previous items

  • Replace them as data loads

  • Good UX, but maybe overkill unless users deep-link often


// Laravel Controller
return Inertia::render('Posts/Index', [
    'posts' => Post::paginate(10),
]);


<!-- Vue 3 Component -->
<template>
  <div ref="scrollContainer">
    <PostCard v-for="post in posts.data" :key="post.id" :post="post" />
    <InfiniteLoader @load="loadMore" />
  </div>
</template>


๐Ÿง  My Question: Whatโ€™s the best approach to handling infinite scroll when a user lands on a deep page (e.g., ?page=5)?

Do you prefetch previous pages on the backend?

Do you backfill them in Vue?

Or do you just say โ€œpage 5 is page 1 nowโ€ and continue scrolling forward?

Any tips on performance or UX trade-offs?

Would love to hear how others are handling this โ€” especially in real-world apps with large datasets or user-generated content feeds.

Thanks in advance! ๐Ÿ™

1 like
1 reply

Please or to participate in this conversation.