Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Supabase 8 min read How-to mediumAdept

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

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.

Related posts

  • Fetching and caching Supabase data in Next.js 13 Server Components

    Supabase mediumAdept

    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. The walkthrough covers four strategies: static generation with `generateStaticParams`, incremental revalidation (e.g. `revalidate = 60`), fully dynamic fetching (`revalidate = 0`), and client components using `use client`. It closes with a hybrid pattern that loads initial data in a Server Component and passes it to a Client Component subscribed to Supabase Realtime Postgres changes, which separates data fetching from caching policy.

  • Using React Query with Next.js App Router and Supabase Cache Helpers

    Supabase mediumAdept

    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. Supabase Cache Helpers generate query keys automatically from supabase-js queries, so one reusable query function can be prefetched in a server component and hydrated through HydrationBoundary, letting the client render without a loading state, or fetched purely client-side. The recommendation is to reach for React Query with Server Components only when migrating an existing React Query app or when it covers needs the framework doesn't; otherwise start with the framework's own data fetching.

  • Coding the stars - an interactive constellation with Three.js and React Three Fiber

    Supabase mediumAdept

    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. Each particle is a low-sided circle geometry with additive blending, positioned every frame in useFrame using sin/cos of elapsed time, with the cosine sign flipped on alternate loops to form the figure eight. Randomized speed, delay offsets and Math.pow-based path offsets concentrate particles toward the shape's core. A dat.gui debug panel, loaded via dynamic import to avoid SSR window errors, was wired to React state so the team could tune parameters and settle on the final design.

  • How we built it: incident.io Status Pages

    incident.io mediumAdept

    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. Pages are pre-built via generateStaticParams, added on demand when created, and refreshed with stale-while-revalidate, while the client uses the SWR library with a 10s refreshInterval, revalidateOnFocus and server-rendered fallbackData for live updates. Server rendering is pinned to Vercel's Dublin region next to the API, and live-reload requests are proxied through Next rewrites. The main pain point was hydration mismatches from relative times and locale/time-zone formatting, handled with explicit luxon zones/locales and lint rules against unguarded "now".

  • Supabase is now compatible with Next.js 14

    Supabase mediumAdept

    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. Now that Server Actions are stable, auth and mutations can run entirely server-side next to the Server Components that fetch data. supabase-js stores sessions in localStorage by default, which doesn't exist on the server, so it has to be configured with cookie-based storage on both server and browser. The new @supabase/ssr package and a create-next-app starter template (`-e with-supabase`) wrap that boilerplate.

The quest for software engineering knowledge.

Look:
Layout: