---
title: "Infinite scroll with Next.js, Framer Motion, and Supabase"
description: "Infinite scroll can be built in Next.js by server-rendering the first 20 rows via getServerSideProps, then loading further pages from Supabase with offset-based .range() queries as the user nears the bottom of the list."
url: "https://swe.quest/articles/infinite-scroll-with-next-js-framer-motion-and-supabase-6453fe47f3aef6ee"
canonical: "https://supabase.com/blog/infinite-scroll-with-nextjs-framer-motion"
source: "Supabase"
published: "2023-04-04"
difficulty: "medium"
kind: "How-to"
reading_minutes: 8
tags: ["react","frontend","javascript"]
---

# Infinite scroll with Next.js, Framer Motion, and Supabase

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2023-04-04, 8 min read, How-to. Original: [https://supabase.com/blog/infinite-scroll-with-nextjs-framer-motion](https://supabase.com/blog/infinite-scroll-with-nextjs-framer-motion)

## Summary

Infinite scroll can be built in Next.js by server-rendering the first 20 rows via getServerSideProps, then loading further pages from Supabase with offset-based .range() queries as the user nears the bottom of the list. A lodash-debounced window scroll listener (200 ms) compares the container's getBoundingClientRect bottom against innerHeight to trigger fetches, and the listener stops once a page returns fewer than PAGE\_COUNT rows. Framer Motion wraps each item to fade and slide it in, with a staggered delay recalculated so newly appended batches animate independently of earlier ones.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [React](https://swe.quest/tags/react.md) (Web & mobile)
- [Frontend](https://swe.quest/tags/frontend.md) (Web & mobile)
- [JavaScript](https://swe.quest/tags/javascript.md) (Languages)

## Prerequisites

- React hooks ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))
- Next.js getServerSideProps ([easy posts on React](https://swe.quest/tags/react.md?difficulty=easy))

## Keywords

Next.js, Supabase, Framer Motion, lodash, supabase-js

## Related posts

- [Fetching and caching Supabase data in Next.js 13 Server Components](https://swe.quest/articles/fetching-and-caching-supabase-data-in-next-js-13-server-components-3caa6b52da5f9612.md): Supabase · 2022-11-17 · Medium · 11 min read · React, Frontend, Caching, Real-time systems
  Next.js 13's app directory lets async Server Components query Supabase directly, with caching controlled by an exported \`revalidate\` value instead of separate getStaticProps/getServerSideProps functions.
- [Using React Query with Next.js App Router and Supabase Cache Helpers](https://swe.quest/articles/using-react-query-with-next-js-app-router-and-supabase-cache-helpers-aaf0cb6afda9d12f.md): Supabase · 2024-01-12 · Medium · 7 min read · React, Frontend, Caching, TypeScript
  React Query can be paired with supabase-js in a Next.js App Router app by wrapping the root layout in a client-side QueryClientProvider and creating typed browser and server Supabase clients via @supabase/ssr.
- [Coding the stars - an interactive constellation with Three.js and React Three Fiber](https://swe.quest/articles/coding-the-stars-an-interactive-constellation-with-three-js-and-react-three-5ccc7dd966bd420d.md): Supabase · 2023-08-04 · Medium · 10 min read · React, Frontend, JavaScript
  Supabase built its Launch Week 8 visual as an animated constellation where each user ticket signup becomes a star particle tracing an "8" shape, using Three.js via React Three Fiber in Next.js.
- [How we built it: incident.io Status Pages](https://swe.quest/articles/how-we-built-it-incident-io-status-pages-37acc4f93c86c23d.md): incident.io · 2023-04-19 · Medium · 8 min read · Caching, React, Frontend, Serverless, CDN & edge
  incident.io built its Status Pages product in three months on Vercel and Next.js, using Incremental Static Regeneration with per-fetch revalidate times (e.g. 30s) so the backend serves only a couple of requests per minute regardless of traffic spikes.
- [Supabase is now compatible with Next.js 14](https://swe.quest/articles/supabase-is-now-compatible-with-next-js-14-76a3d4ceac89740e.md): Supabase · 2023-11-01 · Medium · 4 min read · React, Frontend, Identity & auth, JavaScript
  Supabase works across every Next.js 14 rendering context, including App Router Client and Server Components, Route Handlers, Server Actions and Middleware, plus the Pages Router data-fetching functions.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
