Client Libraries

The Supabase Client makes it simple for developers to build secure and scalable products.

Auth

Create new users using signUp(). By default, the user will need to verify their email address before logging in.
If confirmations are disabled the response will contain an access token and also a confirmed_at value, otherwise it will just contain a confirmation_sent_at attribute.

const { error, data } = await supabase.auth.signUp({
email: 'example@email.com',
password: 'example-password',
})

Existing users can log in using signIn().

const { error, data } = await supabase.auth.signIn({
email: 'example@email.com',
password: 'example-password'
})

If there is an email, but no password passed to signIn(), the user will receive a magic link.

const { error, data } = await supabase.auth.signIn({
email: 'example@email.com'
})

Third party logins are also handled through signIn().

const { user, error } = await supabase.auth.signIn({
// provider can be 'github', 'google', 'gitlab', or 'bitbucket'
provider: 'github'
})

Managing data

Since Postgres is a Relational database, the client makes it simple to query tables and fetch related data in one round-trip, using select().

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

You can do advanced filtering to extract only the data that you need.

const { data, error } = await supabase
.from('cities')
.select('name, country_id')
.lt('country_id', 100)
.limit(10)

You can create data easily using insert().

const { data, error } = await supabase
.from('cities')
.insert([
{ name: 'The Shire', country_id: 554 },
{ name: 'Rohan', country_id: 555 },
])

Realtime Changes

The Supabase client makes it simple to listen to realtime database changes, using subscribe().

const mySubscription = supabase
.from('countries')
.on('*', payload => {
console.log('Change received!', payload)
})
.subscribe()

You can even listen to Row Level changes.

const mySubscription = supabase
.from('countries:id.eq.200')
.on('UPDATE', handleRecordUpdated)
.subscribe()

Next steps