This is a demo exploring using React 18 Server components as a mechanism to load more and render more data in an infinite scrolling list. The project is made in Next.js 13 in the

app
dir.

It works by using query params. By default, one "page" is loaded. As you scorll down, a client component containing an IntersectionOvserver is triggered, which adds

1
to the query param using
router.replace
. The reason it's
.replace
and not
.push
to not fill the history with query params, so that the back button still works as expected. Then
router.refresh()
is called to tell Next to keep the scroll position. (Still exploring that part)

All in all, this setup causes some server components to render, refreshing the page, while still keeping the scroll position.

The reason why it's resonably fast is because it uses the Edge Runtime on Vercel to render, which has no cold boot time.