Quickstart
Giyan works with the official supabase-js. These steps take you from an empty project to an app with users, data, files and realtime.
-
Get your project URL and key
Once you have access and have created a project in the panel, you need two things: the project URL, which looks like
https://<ref>.giyanapp.ir, and theanonkey. Both are on the project page in the panel. -
Install the library
npm install @supabase/supabase-js -
Connect
import { createClient } from '@supabase/supabase-js' const supabase = createClient( 'https://<ref>.giyanapp.ir', // project URL, from the panel '<anon-key>' // anon key, from the panel )The
anonkey is meant for client-side code, provided RLS is enabled on your tables. Never put theservice_rolekey in an app or a browser. -
Sign a user in
Sign-in with email and password. Create the user with
signUpor from Studio.const { data, error } = await supabase.auth.signInWithPassword({ email: 'sara@example.com', password: 'a-long-password', }) if (error) console.error(error.message) else console.log('signed in as', data.user.id) -
Create a table and enable RLS
Run this SQL in Studio. With this policy, each user sees and changes only their own notes.
create table public.notes ( id bigint generated always as identity primary key, user_id uuid not null default auth.uid() references auth.users (id), body text not null, created_at timestamptz not null default now() ); alter table public.notes enable row level security; create policy "own notes" on public.notes for all to authenticated using (user_id = auth.uid()) with check (user_id = auth.uid()); -
Write and read
A signed-in user gets back only their own rows. RLS does that, not your code.
const { error } = await supabase.from('notes').insert({ body: 'Hello Giyan' }) const { data: notes } = await supabase .from('notes') .select('id, body, created_at') .order('created_at', { ascending: false }) -
Upload a file
First create a bucket and let each user write to their own folder:
insert into storage.buckets (id, name) values ('avatars', 'avatars'); create policy "own folder" on storage.objects for all to authenticated using (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text) with check (bucket_id = 'avatars' and (storage.foldername(name))[1] = auth.uid()::text);Then upload from your app:
const { data: { user } } = await supabase.auth.getUser() // file is a File or Blob, for example from <input type="file"> const { error } = await supabase.storage .from('avatars') .upload(`${user.id}/avatar.png`, file, { upsert: true }) -
Listen to changes
Add the table to the realtime publication:
alter publication supabase_realtime add table public.notes;And subscribe in your app:
const channel = supabase .channel('notes') .on( 'postgres_changes', { event: 'INSERT', schema: 'public', table: 'notes' }, (payload) => console.log('new note', payload.new) ) .subscribe()
The rest is the supabase-js documentation. What Giyan does not have yet is listed on the features page.
Want to try it?
The Giyan panel is invite-only for now. Fill in the request form and we will review it.