Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Move upgrade guides

dannykng679de08aa14b
diff --git a/apps/docs/docs/reference/dart/upgrade-guide.mdx b/apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
similarity index 68%
rename from apps/docs/docs/reference/dart/upgrade-guide.mdx
rename to apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
index 707cdd06129..6da7b0c0fe5 100644
--- a/apps/docs/docs/reference/dart/upgrade-guide.mdx
+++ b/apps/docs/docs/ref/dart/v0/upgrade-guide.mdx
@@ -4,23 +4,35 @@ title: Upgrade to supabase-flutter v1
description: 'Learn how to upgrade to supabase-flutter v1.'
---
-import Tabs from '@theme/Tabs'
-import TabItem from '@theme/TabItem'
-
-supabase-flutter focuses on improving the developer experience and making it easier to use. This guide will help you upgrade from supabase-flutter v0 to v1.
+supabase-flutter focuses on improving the developer experience and making it easier to use. This guide demonstrates how to upgrade from supabase-flutter v0 to v1.
## Upgrade the client library
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
Update the package in your pubspec.yaml file.
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
```yaml
supabase_flutter: ^1.0.0
```
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
## Error handling
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
The way supabase-flutter throws error has changed in v1. In v0, errors were returned as a response. In v1, errors are thrown as exceptions. This makes it more intuitive as a Flutter developer to handle errors.
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -52,11 +64,20 @@ try {
</TabPanel>
</Tabs>
-## Auth classes / methods
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+## Auth classes and methods
### Usage of `SupabaseAuthState` and `SupabaseAuthRequiredState` classes
-In v0, `SupabaseAuthState` and `SupabaseAuthRequiredState` were required to handle automatic token refresh and to listen to auth state change. In v1, `SupabaseAuthState` and `SupabaseAuthRequiredState` are deprecated, and token refresh will happen automatically just by initializing Supabase. [`onAuthStateChange`](/docs/reference/dart/upgrade-guide#listening-to-auth-state-change) can be used to action on auth state change.
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
+In v0, `SupabaseAuthState` and `SupabaseAuthRequiredState` were required to handle automatic token refresh and to listen to auth state change. In v1, `SupabaseAuthState` and `SupabaseAuthRequiredState` are deprecated, and token refresh will happen automatically just by initializing Supabase. [`onAuthStateChange`](#listening-to-auth-state-change) can be used to action on auth state change.
+
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
<Tabs
scrollable
@@ -97,10 +118,19 @@ await Supabase.initialize(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
### Listening to auth state change
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
`onAuthStateChange` now returns a `Stream`.
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -135,9 +165,18 @@ authSubscription.cancel();
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
### Sign in with email and password
-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).
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
+`signIn()` 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).
+
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
<Tabs
scrollable
@@ -161,8 +200,17 @@ await supabase.auth.signInWithPassword(email: email, password: password);
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Sign in with magic link
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -185,8 +233,17 @@ await supabase.auth.signInWithOtp(email: email);
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Sign in with a third-party OAuth provider
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -218,8 +275,17 @@ await supabase.auth.signInWithOAuth(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Sign in with phone
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -248,8 +314,17 @@ await supabase.auth.signInWithPassword(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Sign in with phone using OTP
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -281,8 +356,17 @@ await supabase.auth.verifyOTP(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Reset password for email
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -312,8 +396,17 @@ await supabase.auth.resetPasswordForEmail(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Get the user's current session
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -336,8 +429,17 @@ final Session? session = supabase.auth.currentSession;
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Get the logged-in user
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -360,8 +462,17 @@ final User? user = supabase.auth.currentUser;
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Update user data for a logged-in user
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -390,16 +501,23 @@ await supabase.updateUser(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
## Data methods
-`.insert()` / `.upsert()` / `.update()` / `.delete()` don't return rows by default.
+`.insert()` / `.upsert()` / `.update()` / `.delete()` no longer return rows by default. Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), 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.
-Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), 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.
+Also, calling `.execute()` at the end of the query was a requirement in v0, but deprecated in v1.
-Also, calling `.execute()` at the end of the query was a requirement in v0, but in v1 `.execute` is deperecated.
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
### Insert without returning inserted data
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -426,8 +544,17 @@ await supabase.from('my_table').insert(data);
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Insert with returning inserted data
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -453,12 +580,21 @@ final insertedData = await supabase.from('my_table').insert(data).select();
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
## Realtime methods
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Stream
`.stream()` no longer needs the `.execute()` at the end. Also, filtering by `eq` is a lot easier now. `primaryKey` is now a named parameter to make it more obvious what to pass.
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -486,8 +622,17 @@ supabase.from('my_table')
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Subscribe
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -522,8 +667,17 @@ channel.on(
</TabPanel>
</Tabs>
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
+
+<RefSubLayout.EducationRow>
+ <RefSubLayout.Details>
+
### Unsubscribe
+ </RefSubLayout.Details>
+ <RefSubLayout.Examples>
+
<Tabs
scrollable
size="small"
@@ -545,3 +699,6 @@ await supabase.removeChannel(channel);
</TabPanel>
</Tabs>
+
+ </RefSubLayout.Examples>
+</RefSubLayout.EducationRow>
diff --git a/apps/docs/docs/ref/javascript/upgrade-guide.mdx b/apps/docs/docs/ref/javascript/v1/upgrade-guide.mdx
similarity index 100%
rename from apps/docs/docs/ref/javascript/upgrade-guide.mdx
rename to apps/docs/docs/ref/javascript/v1/upgrade-guide.mdx
diff --git a/apps/docs/docs/reference/javascript/upgrade-guide.mdx b/apps/docs/docs/reference/javascript/upgrade-guide.mdx
deleted file mode 100644
index 282d66d4966..00000000000
--- a/apps/docs/docs/reference/javascript/upgrade-guide.mdx
+++ /dev/null
@@ -1,439 +0,0 @@
----
-id: upgrade-guide
-title: Upgrade to supabase-js v2
-description: 'Learn how to upgrade to supabase-js v2.'
----
-
-import Tabs from '@theme/Tabs'
-import TabItem from '@theme/TabItem'
-
-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
-
-```sh
-npm install @supabase/supabase-js@2
-```
-
-_Optionally_ if you are using custom configuration with `createClient` then follow below:
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts title=src/supabaseClient.ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- schema: 'custom',
- persistSession: false,
-})
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts title=src/supabaseClient.ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- db: {
- schema: 'custom',
- },
- auth: {
- persistSession: true,
- },
-})
-```
-
-</TabPanel>
-</Tabs>
-
-Read more about the [constructor options](/docs/reference/javascript/release-notes#explicit-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
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { user, error } = await supabase.auth.signIn({ email, password })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const {
- data: { user },
- error,
-} = await supabase.auth.signInWithPassword({ email, password })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Sign in with magic link
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { error } = await supabase.auth.signIn({ email })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { error } = await supabase.auth.signInWithOtp({ email })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Sign in with a third-party provider
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { error } = await supabase.auth.signIn({ provider })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { error } = await supabase.auth.signInWithOAuth({ provider })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Sign in with phone
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { error } = await supabase.auth.signIn({ phone, password })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { error } = await supabase.auth.signInWithPassword({ phone, password })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Sign in with phone using OTP
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { error } = await supabase.auth.api.sendMobileOTP(phone)
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { data, error } = await supabase.auth.signInWithOtp({ phone })
-
-// After receiving a SMS with a OTP.
-const { data, error } = await supabase.auth.verifyOtp({ phone, token })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Reset password for email
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { data, error } = await supabase.auth.api.resetPasswordForEmail(email)
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { data, error } = await supabase.auth.resetPasswordForEmail(email)
-```
-
-</TabPanel>
-</Tabs>
-
-#### Get the user's current session
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const session = supabase.auth.session()
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const {
- data: { session },
-} = await supabase.auth.getSession()
-```
-
-</TabPanel>
-</Tabs>
-
-#### Get the logged-in user
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const user = supabase.auth.user()
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const {
- data: { session },
-} = await supabase.auth.getSession()
-const { user } = session
-```
-
-</TabPanel>
-</Tabs>
-
-#### Update user data for a logged-in user
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { user, error } = await supabase.auth.update({ attributes })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const {
- data: { user },
- error,
-} = await supabase.auth.updateUser({ attributes })
-```
-
-</TabPanel>
-</Tabs>
-
-#### Use a custom `access_token` JWT with Supabase
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { user, error } = supabase.auth.setAuth(access_token)
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY, {
- global: {
- headers: {
- Authorization: `Bearer ${access_token}`,
- },
- },
-})
-```
-
-</TabPanel>
-</Tabs>
-
-#### Cookie methods
-
-The cookie-related methods like `setAuthCookie` and `getUserByCookie` have been removed.
-
-For Next.js you can use the [Auth Helpers](https://supabase.com/docs/guides/auth/auth-helpers/nextjs) to help you manage cookies.
-If you can't use the Auth Helpers, you can use [server-side rendering](https://supabase.com/docs/guides/auth/server-side-rendering).
-
-Some the [PR](https://github.com/supabase/gotrue-js/pull/340) for additional background information.
-
-### Data methods
-
-`.insert()` / `.upsert()` / `.update()` / `.delete()` don't return rows by default: [PR](https://github.com/supabase/postgrest-js/pull/276).
-
-Previously, these methods return inserted/updated/deleted rows by default (which caused [some confusion](https://github.com/supabase/supabase/discussions/1548)), 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
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { data, error } = await supabase.auth.insert({ new_data })
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { data, error } = await supabase.auth.insert({ new_data }).select()
-```
-
-</TabPanel>
-</Tabs>
-
-#### Update and return data
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const { data, error } = await supabase.auth.update({ new_data }).eq('id', id)
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const { data, error } = await supabase.auth.update({ new_data }).eq('id', id).select()
-```
-
-</TabPanel>
-</Tabs>
-
-### Realtime methods
-
-#### Subscribe
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-const userListener = supabase
- .from('users')
- .on('*', (payload) => handleAllEventsPayload(payload.new))
- .subscribe()
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-const userListener = supabase
- .channel('public:user')
- .on('postgres_changes', { event: '*', schema: 'public', table: 'user' }, (payload) =>
- handleAllEventsPayload()
- )
- .subscribe()
-```
-
-</TabPanel>
-</Tabs>
-
-#### Unsubscribe
-
-<Tabs
- scrollable
- size="small"
- type="underlined"
- defaultActiveId="1.0x"
->
-<TabPanel id="1.0x" label="Before">
-
-```ts
-userListener.unsubscribe()
-```
-
-</TabPanel>
-<TabPanel id="2.0x" label="After">
-
-```ts
-supabase.removeChannel(userListener)
-```
-
-</TabPanel>
-</Tabs>