@jeffreyway has some good techniques in this series:
: 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! ๐
Please or to participate in this conversation.