---
title: "Fetching and caching Supabase data in Next.js 13 Server Components"
description: "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."
url: "https://swe.quest/articles/fetching-and-caching-supabase-data-in-next-js-13-server-components-3caa6b52da5f9612"
canonical: "https://supabase.com/blog/fetching-and-caching-supabase-data-in-next-js-server-components"
source: "Supabase"
published: "2022-11-17"
difficulty: "medium"
kind: "How-to"
reading_minutes: 11
tags: ["react","frontend","caching","realtime"]
---

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

A post on [Supabase](https://swe.quest/sources/supabase.md), published 2022-11-17, 11 min read, How-to. Original: [https://supabase.com/blog/fetching-and-caching-supabase-data-in-next-js-server-components](https://supabase.com/blog/fetching-and-caching-supabase-data-in-next-js-server-components)

## Summary

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.

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)
- [Caching](https://swe.quest/tags/caching.md) (Backend & APIs)
- [Real-time systems](https://swe.quest/tags/realtime.md) (Backend & APIs)

## Prerequisites

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

## Keywords

Next.js 13, React Server Components, Supabase, Suspense, supabase-js, Supabase Realtime

## Related posts

- [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.
- [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.
- [supabase-js v2](https://swe.quest/articles/supabase-js-v2-f87cba2e3b41f9e9.md): Supabase · 2022-08-16 · Medium · 5 min read · JavaScript, TypeScript, API design, Identity & auth, PostgreSQL
  supabase-js v2 brings incremental quality-of-life changes over v1.
- [Cal.com launches Expert Marketplace built with Next.js and Supabase.](https://swe.quest/articles/cal-com-launches-expert-marketplace-built-with-next-js-and-supabase-2659e9baa272f3f6.md): Supabase · 2024-06-18 · Medium · 5 min read · PostgreSQL, Frontend, Serverless, Storage systems
  Cal.com's open-source Platform Starter Kit for building expert marketplaces runs on Next.js and Supabase, having switched from SQLite to Postgres via Prisma shortly before launch once file storage was needed.
- [Making a Real-Time Chat App with Supabase on Replit](https://swe.quest/articles/making-a-real-time-chat-app-with-supabase-on-replit-0a77c4de25e9cc9d.md): Replit · 2022-03-23 · Medium · 8 min read · Real-time systems, Frontend, JavaScript, PostgreSQL
  A real-time public chat app can be built with a Vue 3 and Tailwind CSS frontend on Replit backed by Supabase's hosted Postgres.

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)
