Overview

Learn how Supabase provides PostgreSQL hosting for Plainform's database infrastructure

Supabase serves as the PostgreSQL hosting provider for Plainform, offering a managed database instance that Plainform connects to via Prisma ORM. Plainform also includes the Supabase JavaScript client so projects can opt into Supabase features such as Edge Functions, Storage, or real-time subscriptions without adding setup from scratch.

What Supabase Provides

Supabase hosts your PostgreSQL database and provides:

  • Managed PostgreSQL Database: A fully managed PostgreSQL instance with automatic backups and scaling
  • Connection Pooling: Built-in connection pooling via PgBouncer for better performance
  • Dashboard Access: Web-based interface to view tables, run SQL queries, and manage your database
  • Direct and Pooled Connections: Two connection strings for different use cases (migrations vs. queries)

How Plainform Uses Supabase

Plainform interacts with the Supabase-hosted PostgreSQL database through Prisma ORM:

  • Database Queries: All CRUD operations use Prisma Client (not Supabase client)
  • Schema Management: Database schema is defined in prisma/schema.prisma
  • Migrations: Database migrations are managed via Prisma Migrate
  • Type Safety: Prisma generates TypeScript types from your schema

The Supabase client is available for optional platform features, but Prisma remains the default database access layer.

Default RLS Policies

Plainform includes Prisma migrations that configure Supabase grants and Row Level Security for the default tables:

TablePublishable key accessSecret key accessPrisma access
EventRead onlyRead/writeRead/write
UserNo accessRead/writeRead/write

These policies protect private user and billing data while still allowing public event reads through the Supabase JavaScript client. They are applied when you run npx prisma migrate dev locally or npx prisma migrate deploy in production.

RLS affects Supabase API calls like supabase.from('User'). It does not block Prisma-backed server code such as Clerk webhooks, Stripe webhooks, or API routes that use prisma.user or prisma.event.

Using Supabase Features (Optional)

Plainform includes @supabase/supabase-js and helper clients in lib/supabase for optional Supabase features:

  • Supabase Auth: Alternative to Clerk for authentication
  • Supabase Storage: Alternative to AWS S3 for file storage
  • Real-time Subscriptions: Live data updates for collaborative features
  • Edge Functions: Serverless functions hosted on Supabase
  • Row-Level Security (RLS): Database-level access control policies

Use the browser/client component helper:

lib/supabase/client.ts
import { supabase } from '@/lib/supabase/client';

const { data, error } = await supabase.functions.invoke('hello-world');

For server-only usage, import supabaseServer from @/lib/supabase/server. For trusted admin operations that require the Supabase secret key, use getSupabaseAdmin from @/lib/supabase/admin.

For detailed integration guides, see the Supabase Documentation.

Alternative PostgreSQL Providers

Since Plainform uses standard PostgreSQL via Prisma, you can easily switch to other PostgreSQL hosting providers:

  • Vercel Postgres: Integrated with Vercel deployments
  • Railway: Simple PostgreSQL hosting with automatic backups
  • Neon: Serverless PostgreSQL with branching
  • AWS RDS: Enterprise-grade managed PostgreSQL
  • Self-hosted: Your own PostgreSQL instance

Simply update the DATABASE_URL and DIRECT_URL environment variables to point to your new provider.

Learn More

For database operations and Prisma usage, see the Database section. For Supabase-specific features beyond PostgreSQL hosting, consult the Supabase Documentation.

How is this guide ?

Last updated on

On this page