Upgrade guide
supabase-js v2 focuses on "quality-of-life" improvements for developers and addresses some of the largest pain points in v1. v2 includes type support, a rebuilt Auth library with async methods, improved errors, and more.
No new features will be added to supabase-js v1 , but we'll continuing merging security fixes to v1, with maintenance patches for the next 3 months.
Upgrade the client library#
Install the latest version
Optionally if you are using custom configuration with createClient
then follow below:
Read more about the constructor options.
Auth methods#
The signIn() method has been deprecated in favor of more explicit method signatures to help with type hinting. Previously it was difficult for developers to know what they were missing (e.g., a lot of developers didn't realize they could use passwordless magic links).
Sign in with email and password#
Sign in with magic link#
Sign in with a third-party provider#
Sign in with phone#
Sign in with phone using OTP#
Reset password for email#
Get the user's current session#
Get the logged-in user#
Update user data for a logged-in user#
Use a custom access_token
JWT with Supabase#
Cookie methods#
The cookie-related methods like setAuthCookie
and getUserByCookie
have been removed.
For Next.js you can use the Auth Helpers to help you manage cookies. If you can't use the Auth Helpers, you can use server-side rendering.
Some the PR for additional background information.
Data methods#
.insert()
/ .upsert()
/ .update()
/ .delete()
don't return rows by default: PR.
Previously, these methods return inserted/updated/deleted rows by default (which caused some confusion), and you can opt to not return it by specifying returning: 'minimal'
. Now the default behavior is to not return rows. To return inserted/updated/deleted rows, add a .select()
call at the end.
Insert and return data#
Update and return data#
Upsert and return data#
Delete and return data#
Realtime methods#
Subscribe#
Unsubscribe#