ScaleRocket/Web

Supabase Setup

Configure your Supabase project — database, authentication providers, storage, and Row Level Security.

Supabase Setup

Supabase is the backend for ScaleRocket. It handles your database (PostgreSQL), authentication, file storage, and Edge Functions.

Create a Supabase Project

  1. Go to supabase.com/dashboard
  2. Click New project
  3. Fill in:
    • Name — your project name
    • Database password — save this somewhere safe
    • Region — choose the closest to your users
  4. Wait for provisioning to finish

Get Your API Keys

Go to Settings > API in your Supabase dashboard. You need three values:

KeyWhere to useExposed to client?
Project URLAll appsYes
anon public keyAll appsYes (safe to expose)
service_role keyEdge Functions, server-side onlyNo (keep secret)
# apps/app/.env.local
VITE_SUPABASE_URL=https://abcdefg.supabase.co
VITE_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Note: The anon key is safe for the client. It works with Row Level Security to restrict access. The service_role key bypasses RLS — never expose it to the browser.

Database Schema

ScaleRocket includes migrations in supabase/migrations/ that create the following tables:

TablePurpose
profilesUser profile data (linked to auth.users)
subscriptionsStripe subscription state per user
creditsCredit balance and usage tracking
productsSynced Stripe products
pricesSynced Stripe prices
blog_postsBlog content managed from admin panel

Push Migrations

Link your project and push the schema:

# Login to Supabase CLI
npx supabase login

# Link to your project (find ref in dashboard URL)
npx supabase link --project-ref your-project-ref

# Push all migrations
npx supabase db push

Create a New Migration

When you need to change the schema:

npx supabase migration new my_migration_name

This creates a new file in supabase/migrations/. Write your SQL, then push:

npx supabase db push

Configure Auth Providers

ScaleRocket supports email/password, Google, and GitHub login out of the box.

Google OAuth

  1. Go to Google Cloud Console
  2. Create a new project (or use an existing one)
  3. Go to APIs & Services > Credentials
  4. Create an OAuth 2.0 Client ID (Web application)
  5. Add authorized redirect URI:
    https://your-project-ref.supabase.co/auth/v1/callback
  6. Copy the Client ID and Client Secret
  7. In Supabase dashboard, go to Authentication > Providers > Google
  8. Enable it, paste the Client ID and Secret, and save

GitHub OAuth

  1. Go to GitHub Developer Settings
  2. Click New OAuth App
  3. Set the authorization callback URL:
    https://your-project-ref.supabase.co/auth/v1/callback
  4. Copy the Client ID and Client Secret
  5. In Supabase dashboard, go to Authentication > Providers > GitHub
  6. Enable it, paste the Client ID and Secret, and save

Email Settings

In the Supabase dashboard under Authentication > Email Templates, you can customize:

  • Confirmation email
  • Password reset email
  • Magic link email

Note: For production, configure a custom SMTP server under Settings > Authentication > SMTP Settings so emails come from your domain instead of Supabase's default.

Storage Buckets

ScaleRocket uses Supabase Storage for user-uploaded files (avatars, attachments, etc.).

Create a Bucket

  1. Go to Storage in the Supabase dashboard
  2. Click New bucket
  3. Name it (e.g., avatars)
  4. Choose Public or Private depending on your needs

Storage Policies

For a public avatars bucket, create a policy that lets authenticated users upload:

-- Allow authenticated users to upload their own avatar
CREATE POLICY "Users can upload own avatar"
ON storage.objects FOR INSERT
TO authenticated
WITH CHECK (
  bucket_id = 'avatars' AND
  auth.uid()::text = (storage.foldername(name))[1]
);

-- Allow anyone to view avatars
CREATE POLICY "Public avatar access"
ON storage.objects FOR SELECT
TO public
USING (bucket_id = 'avatars');

Upload from the Client

// apps/app/src/lib/storage.ts
import { supabase } from "./supabase";

export async function uploadAvatar(userId: string, file: File) {
  const filePath = `${userId}/${file.name}`;
  const { data, error } = await supabase.storage
    .from("avatars")
    .upload(filePath, file, { upsert: true });

  if (error) throw error;
  return data.path;
}

Row Level Security

All ScaleRocket tables have RLS enabled by default. This means:

  • The anon key cannot access any data unless a policy explicitly allows it
  • Each user can only read/write their own data
  • The service_role key bypasses RLS (use only in Edge Functions)

Example RLS policy for the profiles table:

-- Users can read their own profile
CREATE POLICY "Users can view own profile"
ON public.profiles FOR SELECT
USING (auth.uid() = id);

-- Users can update their own profile
CREATE POLICY "Users can update own profile"
ON public.profiles FOR UPDATE
USING (auth.uid() = id);

Next Steps

Done reading? Mark this page as complete.

On this page