Supabase Local Development Guide

Run a complete backend with Postgres, Auth, Storage, and more on localhost using Supabase CLI, with the API gateway defaulting to 54321.


Supabase is an open-source alternative to Firebase (PostgreSQL + Auth + Storage + Realtime). The Supabase CLI can launch a full stack in local Docker, making it easy to debug with the frontend.

Prerequisites

brew install supabase/tap/supabase
# or npm i -g supabase

Quick Start

supabase init
supabase start

The CLI will output the local URL and keys, for example:

ServiceTypical localhost Address
APIhttp://localhost:54321
Studiohttp://localhost:54323
PostgreSQLlocalhost:54322
Inbucket (Email Testing)http://localhost:54324

Refer to the ports output by supabase start.

Frontend Connection

.env.local:

NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
NEXT_PUBLIC_SUPABASE_ANON_KEY=<anon key from supabase start>

Common Commands

supabase stop
supabase status
supabase db reset
supabase migration new my_change

Differences from Bare PostgreSQL

The Supabase local stack = Postgres + Auth API + Storage + Kong Gateway; it is not just a :5432 database.

Frequently Asked Questions

Docker Not Running
supabase start depends on Docker; start Docker Desktop first.

Port Conflicts
Adjust [api] port in config.toml, among others.

Summary

Supabase local development runs with supabase start, with the API endpoint typically at http://localhost:54321 and Studio at 54323, suitable for local debugging of full-stack projects like Next.js.

访客计数:------ Best viewed in Netscape Navigator · 800×600 © LocalHost Run