Toolstools / supabase

Supabase

Apa ini

Supabase ialah backend platform.

Ia boleh bagi:

  • Database.
  • Authentication.
  • File storage.

Model simple:

Setting

Frontend = apa user nampak
Backend = tempat data hidup

Kenapa penting

Beginner website boleh kekal frontend-only.

App yang simpan user data biasanya perlukan backend. Supabase useful bila project perlukan saved profiles, bookings, dashboards, uploaded files, atau login.

Apa nak buat

Guna Supabase hanya bila project memang ada data need.

Decide perlu atau tidak

Tanya:

Reference

Does this project need to save user data after refresh?

Kalau no, skip Supabase.

Kalau yes, continue.

Create project

  1. Create account di supabase.com.
  2. Create satu project.
  3. Pilih project name yang match app.
  4. Simpan database password dekat tempat private.
  5. Tunggu dashboard siap provisioning.

Visual checkpoint:

Flow

Supabase Dashboard
  Project selected
  Table Editor visible
  SQL Editor visible
  Authentication visible
  Project Settings -> API visible

Create first table

Start dengan satu table sahaja.

Contoh untuk booking/contact project:

ColumnTypeMaksud
iduuidUnique row ID.
created_attimestampBila row created.
nametextNama customer.
emailtextEmail customer.
messagetextMessage atau booking request.

Tanya AI:

Copy prompt
I am a beginner using Supabase.

My app needs to save:
[describe data]

Suggest one first table only.
Explain each column in simple language.
Do not add authentication yet.

Core features

FeatureMaksudBeginner action
DatabaseSimpan rows app dataStart dengan satu table.
Table EditorDatabase view macam spreadsheetGuna untuk inspect data.
SQL EditorAdvanced database commandsGuna later dengan tutor guidance.
AuthUser login systemAdd hanya bila app betul-betul perlu account.
StorageUploaded filesGuna untuk images/files later.
API keysConnection keys untuk appAnon key boleh client-side; service role key private.
RLSRow Level SecurityKeep enabled dan create policies sebelum real user data.

Connect ke web app

Untuk Next.js project, install client:

Terminal command
npm install @supabase/supabase-js

Add env variables secara local:

Setting

NEXT_PUBLIC_SUPABASE_URL=...
NEXT_PUBLIC_SUPABASE_ANON_KEY=...

Lepas tu add variables yang sama dalam Vercel Project Settings sebelum deploy.

Safety rule

Jangan letak service role key dalam frontend code.

Semak ini:

Setting

Anon key = okay untuk browser use
Service role key = server only, never public

Mistake biasa

  • Tambah Supabase terlalu awal.
  • Start dengan authentication sebelum faham app.
  • Create terlalu banyak table.
  • Copy database code tanpa tahu tempat dia.
  • Turn off Row Level Security tanpa faham risk.
  • Letak service role key dalam .env.local kemudian push.
  • Connect frontend sebelum table design clear.

Next step

Pergi ke Links.