Version: Next

User Management

Introduction

Supabase makes it easy to manage your users.

When a user signs up, Supabase assigns them a unique ID. You can reference this ID anywhere in your database. For example, you might create a profiles table references the user using a user_id field.

Supabase provides the routes to sign up, login, log out, and manage users in your apps and websites.

Sign up

New user.
const {
body: { user },
} = await supabase.auth.signup(
'someone@email.com',
'password'
)

Allow your users to sign up and create a new account.

After they have signed up, all interactions using the Supabase JS client will be performed as "that user".

Log in

Existing user.
const {
body: { user },
} = await supabase.auth.login(
'someone@email.com',
'password'
)

If an account is created, users can login to your app.

After they have logged in, all interactions using the Supabase JS client will be performed as "that user".

User data

Get the logged in user.
const user = await supabase.auth.user()

Get the JSON data for the logged in user.

Log out

Clear the user's session.
await supabase.auth.logout()

After calling log out, all interactions using the Supabase JS client will be "anonymous".

Error handling

Shows how to parse errors returned from the server.
try {
const res = await supabase
.auth
.login('someone@email.com', 'password')
} catch (error) {
if (error.response === undefined) {
// No response from server
} else {
const server_response = error.response
// Here you can further process the response ..
}
if (error.status === undefined) {
// No HTTP status code
} else {
const http_code = error.status
// Further processing ..
}
}