An open API service indexing awesome lists of open source software.

https://github.com/tushcmd/supabase-notes


https://github.com/tushcmd/supabase-notes

Last synced: 3 months ago
JSON representation

Awesome Lists containing this project

README

        

# Supabase

## What is Supabase

An open source alternative to Firebase

- PostgreSQL database with realtime capabilities
- Authenticationa with multiple methods/services
- File storage
- Serverless Functions
- Real-time
- AI and vectors

Build on top of Postgres, a very stable relational database. You can manage your databse from the Supabase interface

- Create tables, relationships, etc
- Write SQL queries
- Enable & disable extensions
- Real-time engine on top of Postgres
- PostgREST API

### User Authentication

Create and manage users from Supabase

- Email/Password
- Magic Link
- Google
- Github
- More...

### Access Control

Security is managed via Postgres RLS (Row Level Security)

#### How It Works

1. A user signs up. Supabase creates a new user in the `auth.users` table.
2. Supabase returns a new JWT, which contains the user's `UUID`.
3. Every request to your database also sends the JWT.
4. Postgres inspects the JWT to determine the user making the request.
5. The user's UID can be used in policies to restcricts access to rows.

##### Allow read access

``` sql
-- 1. Create table
create table profiles (
id uuid references auth.users,
avatar_url text
);

-- 2. Enable RLS
alter table profiles
enable row level security;

-- 3. Create policy
create policy "Public profiles are viewable by everyone"
on profiles for select using (
true
);
```

### Client Libraries

The supabase client makes it easy to access data, authenticate, use storage, etc

``` js
const { error, data } = await supabase.auth.signUp({
email: '[email protected]',
password: 'example-password'
})
```

``` js
const { data, error } = await supabase
.from('countries')
.select('
name,
cities (
name
)
')
```