Quickstarts

Quickstart: Auth

Sign users up and in with supabase-js in 3 steps.

Auth (GoTrue) runs in every project: email + password, magic links, OAuth, MFA and passkeys.

Variables used below: $HOSTBASE_TOKEN (access token), $REF (project ref). SDKs: @hostbase/management (TypeScript) and hostbase_management (Python); full reference at /docs/api.

1. Sign a user up

Use the project's anon key.

curl -X POST https://abcdefghijklmnopqrst.host.ulewicz.space/auth/v1/signup -H "apikey: $ANON_KEY" -H "Content-Type: application/json" \
  -d '{"email":"jan@example.com","password":"correct-horse-battery"}'
const { data, error } = await supabase.auth.signUp({ email: "jan@example.com", password: "correct-horse-battery" });
supabase.auth.sign_up({"email": "jan@example.com", "password": "correct-horse-battery"})
hostbase db query "select count(*) from auth.users"

2. Sign in

The response carries an access_token (JWT) for REST calls under RLS.

curl -X POST "https://abcdefghijklmnopqrst.host.ulewicz.space/auth/v1/token?grant_type=password" -H "apikey: $ANON_KEY" -H "Content-Type: application/json" \
  -d '{"email":"jan@example.com","password":"correct-horse-battery"}'
const { data } = await supabase.auth.signInWithPassword({ email: "jan@example.com", password: "correct-horse-battery" });
session = supabase.auth.sign_in_with_password({"email": "jan@example.com", "password": "correct-horse-battery"})

3. Protect data with RLS

A policy that lets users read only their own rows.

hostbase db push
alter table todos add column user_id uuid default auth.uid();
create policy own_rows on todos for select using (user_id = auth.uid());

Next: /docs/auth, /docs/sso.