Docs
TanStack DB

TanStack DB

Local-first, reactive collections backed by Supabase

A TanStack/db collection backed by Supabase. It wires up Supabase PostgREST queries, mutations, and real-time subscriptions so you get a reactive state that stays in sync with your Postgres database.

Installation

Enter your Supabase project credentials to generate a personalized installation command. The block will include schemas and collections for all tables in your database.

Loading...

What's included

This block installs the following files:

FileDescription
lib/schemas.tsZod schemas for all your database tables
lib/db.tsSupabase collections for type-safe CRUD operations
lib/supabase/client.tsBrowser Supabase client
lib/supabase/server.tsServer-side Supabase client
lib/supabase/middleware.tsMiddleware for session handling
app/providers.tsxProvider component for TanStack DB

Getting started

After installing the block, add the required environment variables to your .env.local file:

NEXT_PUBLIC_SUPABASE_URL=your-project-url
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your-anon-key

Further reading