Supabase Client

By (author)Mutashim Mohsin

Tech stack:
JS
TS
Node.js
Next.js

A lightweight, reusable Supabase client utility. Features a lazy singleton pattern for database access and includes custom error formatting to detect ...
read more
AI Contributions:7
Published At:August 12, 2026
Files Included:1 file(s)
Updated At:October 23, 2026

Read Me

Supabase Client

Lightweight, reusable Supabase browser client for the ScopeFlow app. Provides a lazy singleton client plus a friendly error formatter.

Usage

import {
  getSupabaseClient,
  formatSupabaseError,
} from "../code-gigs/supabase-client";

const supabase = getSupabaseClient();

const { data, error } = await supabase .from("projects") .select("*") .eq("user_id", user.id);

if (error) { throw new Error(formatSupabaseError(error, "Failed to load projects")); }

API

FunctionDescription
getSupabaseClient()Creates and reuses a single @supabase/supabase-js client (persistSession: false). Throws if env vars are missing.
formatSupabaseError(error, fallback)Returns a readable message; detects missing-table / schema-cache errors and explains that supabase/schema.sql must be applied.

Environment variables

NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=your_supabase_publishable_key

Requirements

  • @supabase/supabase-js
  • Use in the browser for data fetching and mutations. Only the public (publishable) key is used — never put secrets here.
  • Server API routes may also import it to query Supabase with the public key and per-user ownership checks.

Loading

Loading

Loading

More like this View all

Groq JSON Client

Server-side Groq API helper that transforms raw client text into structured JSON. It enforces strict schemas grounds requirements in source text and features automatic retry logic.

  • 0

    Ratings

  • 1

    Files

    • JS
    • Next.js
    • +2

    Tech stack

PK Seller Toolkit: Phones, WhatsApp, PKR, Khata

Zero-dependency TypeScript for Pakistani sellers: match phones in any format, wa.me links, Rs formatting, parse "dhai hazar"/"1.5k", khata balances and COD collection. 9 tests.

  • 0

    Ratings

  • 11

    Files

    • TS
    • Node.js
    • +2

    Tech stack

Supabase RLS 4-Tier RBAC Starter with Role Onboard

A reusable Supabase starter for multi-role apps with 4-tier RBAC (learner, instructor, vendor, admin). Includes server-side profile creation after signup (Postgres trigger), role onboarding wizard, Su

  • 0

    Ratings

  • 10

    Files

    • JS
    • TS
    • +2

    Tech stack