https://github.com/tushcmd/supabase-notes
https://github.com/tushcmd/supabase-notes
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/tushcmd/supabase-notes
- Owner: tushcmd
- Created: 2024-06-19T13:27:45.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-22T14:55:19.000Z (12 months ago)
- Last Synced: 2025-01-31T19:14:15.778Z (4 months ago)
- Language: TypeScript
- Size: 1.38 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 vectorsBuild 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
- 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
)
')
```