Pull master and resolve conflicts

This commit is contained in:
Joshen Lim committed 2022-09-27 00:02:35 +08:00
commit dfd5ca618b
520 files changed
+131434 -232221

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
+5 -3
View File
@@ -6,6 +6,8 @@ name: Studio Unit Tests
on:
push:
branches: [ master ]
paths:
- 'studio/**'
pull_request:
branches: [ master ]
paths:
@@ -17,7 +19,7 @@ jobs:
strategy:
matrix:
node-version: [14.x]
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
@@ -28,8 +30,8 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install deps
run: npm i
working-directory: ./studio
run: npm install
working-directory: ./
- name: Run tests
run: npm test
working-directory: ./studio
Executable
+1
View File
@@ -0,0 +1 @@
cookie
+3 -1
View File
@@ -45,7 +45,7 @@ To see how to Contribute, visit [Getting Started](./DEVELOPERS.md)
We are currently in Public Beta. Watch "releases" of this repo to get notified of major updates.
<kbd><img src="https://gitcdn.link/repo/supabase/supabase/master/web/static/watch-repo.gif" alt="Watch this repo"/></kbd>
<kbd><img src="https://raw.githubusercontent.com/supabase/supabase/d5f7f413ab356dc1a92075cb3cee4e40a957d5b1/web/static/watch-repo.gif" alt="Watch this repo"/></kbd>
---
@@ -200,10 +200,12 @@ Our approach for client libraries is modular. Each sub-library is a standalone i
- [Arabic | العربية](/i18n/README.ar.md)
- [Albanian / Shqip](/i18n/README.sq.md)
- [Bangla / বাংলা](/i18n/README.bn.md)
- [Bulgarian / Български](/i18n/README.bg.md)
- [Catalan / Català](/i18n/README.ca.md)
- [Danish / Dansk](/i18n/README.da.md)
- [Dutch / Nederlands](/i18n/README.nl.md)
- [English](https://github.com/supabase/supabase)
- [Finnish / Suomalainen](/i18n/README.fi.md)
- [French / Français](/i18n/README.fr.md)
- [German / Deutsch](/i18n/README.de.md)
- [Greek / Ελληνικά](/i18n/README.gr.md)
+1 -1
View File
@@ -1 +1 @@
web/static/.well-known/security.txt
apps/reference/static/.well-known/security.txt
+1 -2
View File
@@ -19,5 +19,4 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*
# _supabase_js/sdk/**/*
# !_supabase_js/sdk/.gitkeep
**/*/generated
+101 -2
View File
@@ -334,6 +334,9 @@ POST https://api.supabase.com/v1/projects
"ap-south-1",
"sa-east-1"
]
},
"kps_enabled": {
"type": "boolean"
}
},
"required": [
@@ -511,6 +514,18 @@ GET https://api.supabase.com/v1/projects/{ref}/functions
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -583,7 +598,7 @@ POST https://api.supabase.com/v1/projects/{ref}/functions
"properties": {
"slug": {
"type": "string",
"pattern": {}
"pattern": "/^[A-Za-z0-9_-]+$/"
},
"name": {
"type": "string"
@@ -667,6 +682,18 @@ POST https://api.supabase.com/v1/projects/{ref}/functions
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -814,6 +841,18 @@ GET https://api.supabase.com/v1/projects/{ref}/functions/{function_slug}
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -979,6 +1018,18 @@ PATCH https://api.supabase.com/v1/projects/{ref}/functions/{function_slug}
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -1075,6 +1126,18 @@ DELETE https://api.supabase.com/v1/projects/{ref}/functions/{function_slug}
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -1176,6 +1239,18 @@ GET https://api.supabase.com/v1/projects/{ref}/secrets
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -1253,7 +1328,7 @@ POST https://api.supabase.com/v1/projects/{ref}/secrets
},
"value": {
"type": "string",
"pattern": {}
"pattern": "/^(?!SUPABASE_).*/"
}
},
"required": [
@@ -1280,6 +1355,18 @@ POST https://api.supabase.com/v1/projects/{ref}/secrets
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
@@ -1379,6 +1466,18 @@ DELETE https://api.supabase.com/v1/projects/{ref}/secrets
```
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
<TabItem value="403">
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY IF THIS IS VERSION "next" -->
</TabItem>
-337
View File
@@ -1,337 +0,0 @@
---
id: config
slug: /config
title: Configuration
toc_max_heading_level: 3
---
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
A `config.toml` file is generated after running `supabase init`.
This file is located in the `supabase` folder under `supabase/config.toml`.
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## General {#general}
### `project_id` {#project_id}
A string used to distinguish different Supabase projects on the same host. Defaults to the working directory name when running `supabase init`.
<ul>
<li>
Required: <code>true</code>
</li>
<li>
Default: <code>None</code>
</li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## Auth Settings {#auth}
### `auth.site_url` {#auth.site_url}
The base URL of your website. Used as an allow-list for redirects and for constructing URLs used in emails.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>"http://localhost:3000"</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.additional_redirect_urls` {#auth.additional_redirect_urls}
A list of _exact_ URLs that auth providers are permitted to redirect to post authentication.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>["https://localhost:3000"]</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.jwt_expiry` {#auth.jwt_expiry}
How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one week).
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>3600</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.enable_signup` {#auth.enable_signup}
Allow/disallow new user signups to your project.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>true</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.email.enable_signup` {#auth.email.enable_signup}
Allow/disallow new user signups via email to your project.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>true</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.email.double_confirm_changes` {#auth.email.double_confirm_changes}
If enabled, a user will be required to confirm any email change on both the old, and new email addresses. If disabled, only the new email is required to confirm.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>true</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.email.enable_confirmations` {#auth.email.enable_confirmations}
If enabled, users need to confirm their email address before signing in.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>true</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.external.<provider>.enabled` {#auth.external.provider.enabled}
Use an external OAuth provider. The full list of providers are:
- `apple`
- `azure`
- `bitbucket`
- `discord`
- `facebook`
- `github`
- `gitlab`
- `google`
- `twitch`
- `twitter`
- `slack`
- `spotify`
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>true</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.external.<provider>.client_id` {#auth.external.provider.client_id}
Client ID for the external OAuth provider.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>""</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
### `auth.external.<provider>.secret` {#auth.external.provider.secret}
Client secret for the external OAuth provider.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>""</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://supabase.com/docs/reference/auth">Auth Server configuration</a></li></ul>
</li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## API Settings {#api}
### `api.port` {#api.port}
Port to use for the API URL.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>54321</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://postgrest.org/en/stable/configuration.html">PostgREST configuration</a></li></ul>
</li>
</ul>
<br />
### `api.extra_search_path` {#api.extra_search_path}
Extra schemas to add to the `search_path` of every request.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>["extensions"]</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://postgrest.org/en/stable/configuration.html">PostgREST configuration</a></li></ul>
</li>
</ul>
<br />
### `api.max_rows` {#api.max_rows}
The maximum number of rows returned from a view, table, or stored procedure. Limits payload size for accidental or malicious requests.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>1000</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://postgrest.org/en/stable/configuration.html">PostgREST configuration</a></li></ul>
</li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## Database Settings {#database}
### `db.port` {#db.port}
Port to use for the local database URL.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>54322</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://postgrest.org/en/stable/configuration.html">PostgreSQL configuration</a></li></ul>
</li>
</ul>
<br />
### `db.major_version` {#db.major_version}
The database major version to use. This has to be the same as your remote database's. Run `SHOW server_version;` on the remote database to check.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>14</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://postgrest.org/en/stable/configuration.html">PostgreSQL configuration</a></li></ul>
</li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## Dashboard Settings {#dashboard}
### `studio.port` {#studio.port}
Port to use for Supabase Studio.
<ul>
<li>
Required: <code>true</code>
</li>
<li>
Default: <code>54323</code>
</li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## Local Development {#local}
### `inbucket.port` {#inbucket.port}
Port to use for the email testing server web interface.
Emails sent with the local dev setup are not actually sent - rather, they are monitored, and you can view the emails that would have been sent from the web interface.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>54324</code></li>
<li>
<span>See also:</span>
<ul><li><a href="https://www.inbucket.org">Inbucket documentation</a></li></ul>
</li>
</ul>
<br />
File diff suppressed because it is too large. Load diff
+14 -223
View File
@@ -1,244 +1,35 @@
---
id: config
slug: /config
title: Configuration
toc_max_heading_level: 3
---
## Security
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
| Parameter | Type | Description |
| :-------------------------------------------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="site_url">`SITE_URL`</span> | `string` | **Required**. The base URL your site is located at. Currently used in combination with other settings to construct URLs used in emails. Any URI that shares a host with `SITE_URL` is a permitted value for `redirect_to` params (see `/authorize` etc.). |
| <span id="uri_allow_list">`URI_ALLOW_LIST`</span> | `string` | A comma separated list of URIs (e.g. `"https://foo.example.com,https://*.foo.example.com"`) which are permitted as valid `redirect_to` destinations. Defaults to [ ].<br/><br/>Supports wildcard matching through globbing. (e.g. `https://*.foo.example.com` will allow `https://a.foo.example.com` and `https://b.foo.example.com` to be accepted.)<br/><br/>Globbing is also supported on subdomains. (e.g. `https://foo.example.com/*` will allow `https://foo.example.com/page1` and `https://foo.example.com/page2` to be accepted.)<br/>For more common glob patterns, check out the [following link](https://pkg.go.dev/github.com/gobwas/glob#Compile). |
| <span id="operator_token">`OPERATOR_TOKEN`</span> | `string` | The shared secret with an operator for this microservice. Used to verify requests have been proxied through the operator and the payload values can be trusted. |
| <span id="disable_signup">`DISABLE_SIGNUP`</span> | `bool` | When signup is disabled the only way to create new users is through invites. Defaults to `false`, all signups enabled. |
| <span id="email_enabled">`EXTERNAL_EMAIL_ENABLED`</span> | `bool` | Use this to disable email signups (users can still use external oauth providers to sign up / sign in) |
| <span id="phone_enabled">`EXTERNAL_PHONE_ENABLED`</span> | `bool` | Use this to disable phone signups (users can still use external oauth providers to sign up / sign in) |
| <span id="rate_limit_token_refresh">`RATE_LIMIT_TOKEN_REFRESH`</span> | `string` | Rate limit the number of requests sent to `/token` |
| <span id="rate_limit_email_sent">`RATE_LIMIT_EMAIL_SENT`</span> | `string` | Rate limit the number of emails sent per hr on the following endpoints: `/signup`, `/invite`, `/magiclink`, `/recover`, `/otp`, & `/user`. |
| <span id="password_min_length">`PASSWORD_MIN_LENGTH`</span> | `int` | Minimum password length, defaults to 6. |
A `config.toml` file is generated after running `supabase init`.
These options control additional security settings available in gotrue. If self-hosting, they need to be prefixed with `GOTRUE_SECURITY_` .
This file is located in the `supabase` folder under `supabase/config.toml`.
| Parameter | Type | Description |
| :---------------------------------------------------------------------------------------------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="refresh_token_rotation_enabled">`REFRESH_TOKEN_ROTATION_ENABLED`</span> | `bool` | If refresh token rotation is enabled, gotrue will automatically detect malicious attempts to reuse a revoked refresh token. When a malicious attempt is detected, gotrue immediately revokes all tokens that descended from the offending token. |
| <span id="refresh_token_reuse_interval">`REFRESH_TOKEN_REUSE_INTERVAL`</span> | `string` | This setting is only applicable if `REFRESH_TOKEN_ROTATION_ENABLED` is enabled. The reuse interval for a refresh token allows for exchanging the refresh token multiple times during the interval to support concurrency or offline issues.<br/>During the reuse interval, gotrue will not consider using a revoked token as a malicious attempt and will simply return the child refresh token.<br/>Only the previous revoked token can be reused. Using an old refresh token way before the current valid refresh token will trigger the reuse detection. |
| <span id="captcha_enabled">`CAPTCHA_ENABLED`</span> | `string` | Enables the captcha middleware. |
| <span id="captcha_provider">`CAPTCHA_PROVIDER`</span> | `string` | The only captcha provider option supported is: `hcaptcha`. |
| <span id="captcha_secret">`CAPTCHA_SECRET`</span> | `string` | The captcha secret token. Retrieve this from your captcha account. |
| <span id="captcha_timeout">`CAPTCHA_TIMEOUT`</span> | `string` | The http timeout on the captcha request. |
| <span id="update_password_require_reauthentication">`UPDATE_PASSWORD_REQUIRE_REAUTHENTICATION`</span> | `bool` | When enabled, this requires a user to reauthenticate before being able to update their password. |
## API
| Parameter | Type | Description |
| :------------------------------------------------------ | :------- | :--------------------------------------------------------------------------------------------- |
| <span id="api_host">`API_HOST`</span> | `string` | Hostname to listen on. |
| <span id="port">`PORT`</span> | `number` | Port number to listen on. Defaults to `8081`. |
| <span id="request_id_header">`REQUEST_ID_HEADER`</span> | `string` | If you wish to inherit a request ID from the incoming request, specify the name in this value. |
## Database
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
| Parameter | Type | Description |
| :---------------------------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="db_driver">`DB_DRIVER`</span> | `string` | **Required**. Chooses what dialect of database you want. Must be `postgres`. |
| <span id="database_url">`DATABASE_URL`</span> | `string` | **Required**. Connection string for the database. |
| <span id="db_max_pool_size">`DB_MAX_POOL_SIZE`</span> | `int` | Sets the maximum number of open connections to the database. Defaults to 0 which is equivalent to an "unlimited" number of connections. |
| <span id="db_namespace">`DB_NAMESPACE`</span> | `string` | Specifies the schema in which the tables are to be created in. |
## General {#general}
## JSON Web Tokens (JWT)
| Parameter | Type | Description |
| :---------------------------------------------------------------- | :------- | :----------------------------------------------------------------------------------- |
| <span id="jwt_secret">`JWT_SECRET`</span> | `string` | **Required**. The secret used to sign JWT tokens with. |
| <span id="jwt_exp">`JWT_EXP`</span> | `number` | How long tokens are valid for in seconds. Defaults to 3600 (1 hour). |
| <span id="jwt_aud">`JWT_AUD`</span> | `string` | The default JWT audience. Use audiences to group users. Defaults to `authenticated`. |
| <span id="jwt_admin_group_name">`JWT_ADMIN_GROUP_NAME`</span> | `string` | The name of the admin group (if enabled). Defaults to `admin`. |
| <span id="jwt_default_group_name">`JWT_DEFAULT_GROUP_NAME`</span> | `string` | The default group to assign all new users to. |
## External Authentication Providers
### `project_id` {#project_id}
We support `apple`, `azure`, `bitbucket`, `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `spotify`, `slack`, `twitch`, `twitter` and `workos` for external authentication.
A string used to distinguish different Supabase projects on the same host. Defaults to the working directory name when running `supabase init`.
Use the names as the keys underneath `external` to configure each separately.
No external providers are required, but you must provide the required values if you choose to enable any.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
| Parameter | Type | Description |
| :------------------------------------------------------------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <span id="external_x_enabled">`EXTERNAL_X_ENABLED`</span> | `bool` | Whether this external provider is enabled or not |
| <span id="external_x_client_id">`EXTERNAL_X_CLIENT_ID`</span> | `string` | **Required**. The OAuth2 Client ID registered with the external provider. |
| <span id="external_x_client_secret">`EXTERNAL_X_SECRET`</span> | `string` | **Required**. The OAuth2 Client Secret provided by the external provider when you registered. |
| <span id="external_x_redirect_uri">`EXTERNAL_X_REDIRECT_URI`</span> | `string` | **Required**. Also known as the callback url, this is the URI an OAuth2 provider will redirect to with the `code` and `state` values. |
| <span id="external_x_url">`EXTERNAL_X_URL`</span> | `string` | The base URL used for constructing the URLs to request authorization and access tokens. Used by `gitlab` and `keycloak`. For `gitlab` it defaults to `https://gitlab.com`. For `keycloak` you need to set this to your realm url, (e.g. `https://keycloak.example.com/auth/realms/myrealm`) |
<br />
### Apple OAuth
To try out sign-in with Apple locally, you will need to do the following:
1. Run GoTrue over `https` via a reverse proxy (like ngrok).
2. Generate the `crt` and `key` file. See [here](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) for more information.
3. Generate the `GOTRUE_EXTERNAL_APPLE_SECRET` by following this [post](https://medium.com/identity-beyond-borders/how-to-configure-sign-in-with-apple-77c61e336003)!
## SMTP Configuration
Sending email is not required, but highly recommended for password recovery. If `mailer_autoconfirm` is enabled, no emails will be sent out for `signup`, `recovery`, `invite`. Emails will only be sent out for `magiclink`.
| Parameter | Type | Description |
| :-------------------------------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="smtp_admin_email">`SMTP_ADMIN_EMAIL`</span> | `string` | **Required**. The `From` email address for all emails sent. |
| <span id="smtp_host">`SMTP_HOST`</span> | `string` | **Required**. The mail server hostname to send emails through. |
| <span id="smtp_port">`SMTP_PORT`</span> | `string` | **Required**. The port number to connect to the mail server on. |
| <span id="smtp_user">`SMTP_USER`</span> | `string` | **Required**. If the mail server requires authentication, the username to use. |
| <span id="smtp_pass">`SMTP_PASS`</span> | `string` | **Required**. If the mail server requires authentication, the password to use. |
| <span id="smtp_max_frequency">`SMTP_MAX_FREQUENCY`</span> | `string` | Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email. The value is the number of seconds. Defaults to 60 seconds. |
| <span id="smtp_sender_name">`SMTP_SENDER_NAME`</span> | `string` | Sets the name of the sender. Defaults to the `SMTP_ADMIN_EMAIL` if not used. |
## Email
These options control the emails sent from GoTrue.
| Parameter | Type | Description |
| :---------------------------------------------------------------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_autoconfirm">`MAILER_AUTOCONFIRM`</span> | `bool` | If you do not require email confirmation, you may set this to `true`. Defaults to `false`. |
| <span id="mailer_secure_email_change_enabled">`MAILER_SECURE_EMAIL_CHANGE_ENABLED`</span> | `bool` | If `true`, send an email to both the user's current and new email with a confirmation link, otherwise send an email with confirmation link only to new email. Defaults to `true`. |
| <span id="mailer_otp_exp">`MAILER_OTP_EXP`</span> | `string` | Controls the duration an email link or otp is valid for. Defaults to 24 hrs. |
| <span id="mailer_urlpaths_invite">`MAILER_URLPATHS_INVITE`</span> | `string` | URL path to use in the user invite email. Defaults to `/`. |
| <span id="mailer_urlpaths_confirmation">`MAILER_URLPATHS_CONFIRMATION`</span> | `string` | URL path to use in the signup confirmation email. Defaults to `/`. |
| <span id="mailer_urlpaths_recovery">`MAILER_URLPATHS_RECOVERY`</span> | `string` | URL path to use in the password reset email. Defaults to `/`. |
| <span id="mailer_urlpaths_email_change">`MAILER_URLPATHS_EMAIL_CHANGE`</span> | `string` | URL path to use in the email change confirmation email. Defaults to `/`. |
| <span id="mailer_subjects_invite">`MAILER_SUBJECTS_INVITE`</span> | `string` | Email subject to use for user invite. Defaults to `You have been invited`. |
| <span id="mailer_subjects_confirmation">`MAILER_SUBJECTS_CONFIRMATION`</span> | `string` | Email subject to use for signup confirmation. Defaults to `Confirm Your Signup`. |
| <span id="mailer_subjects_recovery">`MAILER_SUBJECTS_RECOVERY`</span> | `string` | Email subject to use for password reset. Defaults to `Reset Your Password`. |
| <span id="mailer_subjects_magiclink">`MAILER_SUBJECTS_MAGIC_LINK`</span> | `string` | Email subject to use for magic link email. Defaults to `Your Magic Link`. |
| <span id="mailer_subjects_email_change">`MAILER_SUBJECTS_EMAIL_CHANGE`</span> | `string` | Email subject to use for email change confirmation. Defaults to `Confirm Email Change`. |
## Email Templates
| Parameter | Type | Description |
| :------------------------------------------------------------------ | :------- | :---------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_templates_invite">`MAILER_TEMPLATES_INVITE`</span> | `string` | URL path to an email template to use when inviting a user. `SiteURL`, `Email`, and `ConfirmationURL` variables are available. |
Default Content (if template is unavailable):
```html
<h2>You have been invited</h2>
<p>
You have been invited to create a user on {{ .SiteURL }}. Follow this link to
accept the invite:
</p>
<p><a href="{{ .ConfirmationURL }}">Accept the invite</a></p>
```
| Parameter | Type | Description |
| :------------------------------------------------------------------------------ | :------- | :-------------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_templates_confirmation">`MAILER_TEMPLATES_CONFIRMATION`</span> | `string` | URL path to an email template to use when confirming a signup. `SiteURL`, `Email`, and `ConfirmationURL` variables are available. |
Default Content (if template is unavailable):
```html
<h2>Confirm your signup</h2>
<p>Follow this link to confirm your user:</p>
<p><a href="{{ .ConfirmationURL }}">Confirm your mail</a></p>
```
| Parameter | Type | Description |
| :---------------------------------------------------------------------- | :------- | :--------------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_templates_recovery">`MAILER_TEMPLATES_RECOVERY`</span> | `string` | URL path to an email template to use when resetting a password. `SiteURL`, `Email`, and `ConfirmationURL` variables are available. |
Default Content (if template is unavailable):
```html
<h2>Reset Password</h2>
<p>Follow this link to reset the password for your user:</p>
<p><a href="{{ .ConfirmationURL }}">Reset Password</a></p>
```
| Parameter | Type | Description |
| :-------------------------------------------------------------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_templates_magic_link">`MAILER_TEMPLATES_MAGIC_LINK`</span> | `string` | URL path to an email template to use when sending magic link. `SiteURL`, `Email`, and `ConfirmationURL` variables are available. |
Default Content (if template is unavailable):
```html
<h2>Magic Link</h2>
<p>Follow this link to login:</p>
<p><a href="{{ .ConfirmationURL }}">Log In</a></p>
```
| Parameter | Type | Description |
| :------------------------------------------------------------------------------ | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="mailer_templates_email_change">`MAILER_TEMPLATES_EMAIL_CHANGE`</span> | `string` | URL path to an email template to use when confirming the change of an email address. `SiteURL`, `Email`, `NewEmail` and `ConfirmationURL` variables are available. |
Default Content (if template is unavailable):
```html
<h2>Confirm Change of Email</h2>
<p>
Follow this link to confirm the update of your email from {{ .Email }} to {{
.NewEmail }}:
</p>
<p><a href="{{ .ConfirmationURL }}">Change Email</a></p>
```
### Phone Auth
These options control the SMS-es sent from GoTrue.
| Parameter | Type | Description |
| :------------------------------------------------------ | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="sms_autoconfirm">`SMS_AUTOCONFIRM`</span> | `bool` | If you do not require phone confirmation, you may set this to `true`. Defaults to `false`. |
| <span id="sms_max_frequency">`SMS_MAX_FREQUENCY`</span> | `number` | Controls the minimum amount of time that must pass before sending another sms otp. The value is the number of seconds. Defaults to 60 (1 minute)). |
| <span id="sms_otp_exp">`SMS_OTP_EXP`</span> | `number` | Controls the duration an sms otp is valid for. |
| <span id="sms_otp_length">`SMS_OTP_LENGTH`</span> | `number` | Controls the number of digits of the sms otp sent. Valid otp lengths are between [6 - 10] digits |
| <span id="sms_provider">`SMS_PROVIDER`</span> | `string` | Available options are: `twilio`, `messagebird`, `textlocal`, and `vonage` |
If you're using twilio, you can obtain your credentials from the [twilio dashboard](https://www.twilio.com/docs/usage/requests-to-twilio#credentials):
You can find the `SMS_TWILIO_ACCOUNT_SID` and `SMS_TWILIO_AUTH_TOKEN` in the account info page of the twilio console dashboard.
| Parameter | Type | Description |
| :---------------------------------------------------------------------------- | :------- | :------------------------------------------- |
| <span id="twilio_account_sid">`SMS_TWILIO_ACCOUNT_SID`</span> | `string` | Your twilio account string identifier (SID). |
| <span id="twilio_auth_token">`SMS_TWILIO_AUTH_TOKEN`</span> | `string` | Your twilio auth token. |
| <span id="twilio_message_service_sid">`SMS_TWILIO_MESSAGE_SERVICE_SID`</span> | `string` | Your twilio sender mobile number |
If you're using MessageBird, you can obtain your credentials from the [MessageBird dashboard](https://dashboard.messagebird.com/en/developers/access):
| Parameter | Type | Description |
| :-------------------------------------------------------------------- | :------- | :----------------------------------------------------------- |
| <span id="messagebird_access_key">`SMS_MESSAGEBIRD_ACCESS_KEY`</span> | `string` | Your MessageBird access key. |
| <span id="messagebird_originator">`SMS_MESSAGEBIRD_ORIGINATOR`</span> | `string` | Your MessageBird sender phone number with + or company name. |
## Logging
| Parameter | Type | Description |
| :-------------------------------------- | :------- | :-------------------------------------------------------------------------------------------------------------------------- |
| <span id="log_level">`LOG_LEVEL`</span> | `string` | Controls what log levels are output. Choose from `panic`, `fatal`, `error`, `warn`, `info`, or `debug`. Defaults to `info`. |
| <span id="log_file">`LOG_FILE`</span> | `string` | If you wish logs to be written to a file, set `log_file` to a valid file path. |
## Opentracing
Currently Datadog is the only tracer supported.
| Parameter | Type | Description |
| :-------------------------------------------------- | :------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="tracing_enabled">`TRACING_ENABLED`</span> | `bool` | Whether tracing is enabled or not. Defaults to `false`. |
| <span id="tracing_host">`TRACING_HOST`</span> | `string` | The tracing destination. (e.g. `GOTRUE_TRACING_HOST=127.0.0.1`) |
| <span id="tracing_port">`TRACING_PORT`</span> | `int` | The port for the tracing host. |
| <span id="tracing_tags">`TRACING_TAGS`</span> | `string` | A comma separated list of key:value pairs. These key value pairs will be added as tags to all opentracing spans. (e.g. `GOTRUE_TRACING_TAGS="tag1:value1,tag2:value2"`) |
| <span id="service_name">`SERVICE_NAME`</span> | `string` | The name to use for the service. |
## Webhooks
| Parameter | Type | Description |
| :---------------------------------------------------------- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <span id="webhook_url">`WEBHOOK_URL`</span> | `string` | URL of the webhook receiver endpoint. This will be called when events like `validate`, `signup` or `login` occur. |
| <span id="webhook_secret">`WEBHOOK_SECRET`</span> | `string` | Shared secret to authorize webhook requests. This secret signs the [JSON Web Signature](https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41) of the request. You _should_ use this to verify the integrity of the request. Otherwise others can feed your webhook receiver with fake data. |
| <span id="webhook_retries">`WEBHOOK_RETRIES`</span> | `number` | How often GoTrue should try a failed hook. |
| <span id="webhook_timeout_sec">`WEBHOOK_TIMEOUT_SEC`</span> | `number` | Time between retries (in seconds). |
| <span id="webhook_events">`WEBHOOK_EVENTS`</span> | `list` | Which events should trigger a webhook. You can provide a comma separated list. For example to listen to all events, provide the values `validate,signup,login`. |
@@ -1,264 +0,0 @@
---
id: config
slug: /config
title: Configuration
toc_max_heading_level: 3
---
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
A sample `.env` file is located in the [storage repository](https://github.com/supabase/storage-api/blob/master/.env.sample).
Use this file to configure your environment variables for your Storage server.
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## General {#general}
### `ANON_KEY` {#ANON_KEY}
A long-lived JWT with anonymous Postgres privileges.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `SERVICE_KEY` {#SERVICE_KEY}
A long-lived JWT with Postgres privileges to bypass Row Level Security.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `TENANT_ID` {#TENANT_ID}
The ID of a Storage tenant.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `REGION` {#REGION}
Region of your S3 bucket.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `GLOBAL_S3_BUCKET` {#GLOBAL_S3_BUCKET}
Name of your S3 bucket.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `POSTGREST_URL` {#POSTGREST_URL}
The URL of your PostgREST server.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `PGRST_JWT_SECRET` {#PGRST_JWT_SECRET}
A JWT Secret for the PostgREST database.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `DATABASE_URL` {#DATABASE_URL}
The URL of your Postgres database.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `PGOPTIONS` {#PGOPTIONS}
Additional configuration parameters for Postgres startup.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `FILE_SIZE_LIMIT` {#FILE_SIZE_LIMIT}
The maximum file size allowed.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `STORAGE_BACKEND` {#STORAGE_BACKEND}
The storage provider.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `FILE_STORAGE_BACKEND_PATH` {#FILE_STORAGE_BACKEND_PATH}
The location storage when the "STORAGE_BACKEND" is set to "file".
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
<!-- AUTOGENERATED: DO NOT EDIT DIRECTLY -->
## Multi-tenant {#multitenant}
### `IS_MULTITENANT` {#IS_MULTITENANT}
Operate across multiple tenants.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `MULTITENANT_DATABASE_URL` {#MULTITENANT_DATABASE_URL}
The URL of the multitenant Postgres database.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `X_FORWARDED_HOST_REGEXP` {#X_FORWARDED_HOST_REGEXP}
TBD.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `POSTGREST_URL_SUFFIX` {#POSTGREST_URL_SUFFIX}
The suffix for the PostgREST instance.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `ADMIN_API_KEYS` {#ADMIN_API_KEYS}
Secure API key for administrative endpoints.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
### `ENCRYPTION_KEY` {#ENCRYPTION_KEY}
An key for encryting/decrypting secrets.
<ul>
<li>Required: <code>true</code></li>
<li>Default: <code>None</code></li>
</ul>
<br />
File diff suppressed because it is too large. Load diff
@@ -1,29 +0,0 @@
---
id: auth-onauthstatechange
title: 'auth.onAuthStateChange()'
slug: /auth-onauthstatechange
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Receive a notification every time an auth event happens.
```dart
final subscription = supabase.auth.onAuthStateChange((event, session) {
print(session?.user?.id);
// handle auth state change
});
```
## Examples
### Listen to auth changes
```dart
final subscription = supabase.auth.onAuthStateChange((event, session) {
print(session?.user?.id);
// handle auth state change
});
```
@@ -1,23 +0,0 @@
---
id: auth-session
title: 'auth.session()'
slug: /auth-session
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Returns the session data, if there is an active session.
```dart
final session = supabase.auth.session();
```
## Examples
### Get the session data
```dart
final session = supabase.auth.session();
```
@@ -1,59 +0,0 @@
---
id: auth-signin
title: 'auth.signIn()'
slug: /auth-signin
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Log in an existing user, or login via a third-party provider.
```dart
final res = await supabase.auth.signIn(email: 'example@email.com', password: 'example-password');
final user = res.data?.user;
final error = res.error;
```
## Notes
- A user can sign up via email, phone number.
- If you provide `email` without a `password`, the user will be sent a magic link.
- The magic link's destination URL is determined by the SITE_URL config variable. To change this, you can go to Authentication -> Settings on [app.supabase.com](https://app.supabase.com)
- Similarly, if you provide `phone` without a `password`, the user will be sent a one time password.
- If you are looking to sign users in with OAuth in Flutter apps, go to [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider).
## Examples
### Sign in with email.
```dart
final res = await supabase.auth.signIn(email: 'example@email.com', password: 'example-password');
final user = res.data?.user;
final error = res.error;
```
### Sign in with magic link.
If email is provided, but no password is provided, the user will be sent a "magic link" to their email address, which they can click to open your application with a valid session. By default, a given user can only request a Magic Link once every 60 seconds.
```dart
final res = await supabase.auth.signIn(email: 'example@email.com');
final error = res.error;
```
### Get OAuth sign in URL.
Passing provider parameter to `signIn()` will return a URL to sign your user in via OAuth.
If you are looking to sign in a user via OAuth on Flutter app, go to [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider).
```dart
final res = await supabase.auth.signIn(provider: Provider.github);
final url = res.data?.url;
final error = res.error;
```
@@ -1,63 +0,0 @@
---
id: auth-signinwithprovider
title: 'auth.signInWithProvider()'
slug: /auth-signinwithprovider
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Signs the user in using third party OAuth providers.
```dart
final res = await supabase.auth.signInWithProvider(Provider.github);
final error = res.error;
```
## Notes
- `auth.signInWithProvider()` is only available on `supabase_flutter`
- It will open the browser to the relevant login page.
## Examples
### Sign in with provider.
```dart
final res = await supabase.auth.signInWithProvider(Provider.github);
final error = res.error;
```
### With `redirectTo`
Specify the redirect link to bring back the user via deeplink.
Note that `redirectTo` should be null for Flutter Web.
```dart
final res = await supabase.auth.signInWithProvider(
Provider.github,
options: AuthOptions(
redirectTo: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/'),
);
final error = res.error;
```
### With scopes
If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.
You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider.
```dart
const { user, session, error } = await supabase.auth.signIn({
provider: 'github'
}, {
scopes: 'repo gist notifications'
})
const oAuthToken = session.provider_token // use to access provider API
```
@@ -1,27 +0,0 @@
---
id: auth-signout
title: 'auth.signOut()'
slug: /auth-signout
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Signs out the current user, if there is a logged in user.
```dart
final res = await supabase.auth.signOut();
final error = res.error;
```
## Examples
### Sign out
```dart
final res = await supabase.auth.signOut();
final error = res.error;
```
@@ -1,40 +0,0 @@
---
id: auth-signup
title: 'auth.signUp()'
slug: /auth-signup
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Creates a new user.
```dart
final res = await supabase.auth.signUp('example@email.com', 'example-password');
final user = res.data?.user;
final error = res.error;
```
## Notes
- By default, the user will need to verify their email address before logging in. If you would like to change this, you can disable "Email Confirmations" by going to Authentication -> Settings on [app.supabase.com](https://app.supabase.com)
- If "Email Confirmations" is turned on, a user is returned but session will be null
- If "Email Confirmations" is turned off, both a `user` and a `session` will be returned
- When the user confirms their email address, they will be redirected to localhost:3000 by default. To change this, you can go to Authentication -> Settings on [app.supabase.com](https://app.supabase.com)
## Examples
### Sign up.
```dart
final res = await supabase.auth.signUp('example@email.com', 'example-password');
final user = res.data?.user;
final error = res.error;
```
### Sign up with third-party providers.
If you are using Flutter, you can sign up with OAuth providers using the [`signInWithProvider()`](/docs/reference/dart/auth-signinwithprovider) method available on `supabase_flutter`.
@@ -1,36 +0,0 @@
---
id: auth-update
title: 'auth.update()'
slug: /auth-update
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Updates user data, if there is a logged in user.
```dart
final res = await supabase.auth.update(
UserAttributes(data: {'hello': 'world'})
);
final error = res.error;
```
## Notes
It's generally better to store user data in a table inside your public schema (i.e. `public.users`).
Use the `update()` method if you have data which rarely changes or is specific only to the logged in user.
## Examples
### Update a user's metadata.
```dart
final res = await supabase.auth.update(
UserAttributes(data: {'hello': 'world'})
);
final error = res.error;
```
@@ -1,23 +0,0 @@
---
id: auth-user
title: 'auth.user()'
slug: /auth-user
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Returns the user data, if there is a logged in user.
```dart
final user = supabase.auth.user();
```
## Examples
### Get the logged in user
```dart
final user = supabase.auth.user();
```
@@ -1,59 +0,0 @@
---
id: containedby
title: '.containedBy()'
slug: /containedby
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.containedBy('main_exports', ['cars', 'food', 'machine'])
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.containedBy('main_exports', ['cars', 'food', 'machine'])
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.containedBy('main_exports', ['orks', 'surveillance', 'evil'])
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.containedBy('main_exports', ['cars', 'food', 'machine'])
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.containedBy('main_exports', ['cars', 'food', 'machine'])
.execute();
```
@@ -1,59 +0,0 @@
---
id: contains
title: '.contains()'
slug: /contains
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.contains('main_exports', ['oil'])
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.contains('main_exports', ['oil'])
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.contains('main_exports', ['oil'])
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.contains('main_exports', ['oil'])
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.contains('main_exports', ['oil'])
.execute();
```
@@ -1,35 +0,0 @@
---
id: delete
title: 'Delete data: delete()'
slug: /delete
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Performs a DELETE on the table.
```dart
final res = await supabase
.from('cities')
.delete()
.match({ 'id': 666 })
.execute();
```
## Notes
- `delete()` should always be combined with [Filters](/docs/reference/dart/using-filters) to target the item(s) you wish to delete.
## Examples
### Delete records
```dart
final res = await supabase
.from('cities')
.delete()
.match({ 'id': 666 })
.execute();
```
@@ -1,61 +0,0 @@
---
id: eq
title: '.eq()'
slug: /eq
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` exactly matches the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The shire')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The shire')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.eq('name', 'San Francisco')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.eq('name', 'Mordor')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.eq('name', 'San Francisco')
.execute();
```
@@ -1,80 +0,0 @@
---
id: filter
title: '.filter()'
slug: /filter
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose `column` satisfies the filter.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
.execute();
```
## Notes
- `.filter()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter names and values, so it should only be used as an escape hatch in case other filters don't work.
```dart
.filter('arraycol','cs','{"a","b"}') // Use Postgres array {} and 'cs' for contains.
.filter('rangecol','cs','(1,2]') // Use Postgres range syntax for range column.
.filter('id','in','(6,7)') // Use Postgres list () and 'in' for in_ filter.
.filter('id','cs','{${mylist.join(',')}}') // You can insert a Dart array list.
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.filter('name', 'in', '("Paris","Tokyo")')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.filter('name', 'in', '("Paris","Tokyo")')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.filter('name', 'in', '("Paris","Tokyo")')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.filter('name', 'in', '("Paris","Tokyo")')
```
### Filter embedded resources
```dart
final res = await supabase
.from('cities')
.select('name, countries ( name )')
.filter('countries.name', 'in', '("France","Japan")')
.execute();
```
@@ -1,23 +0,0 @@
---
id: getsubscriptions
title: 'getSubscriptions()'
slug: /getsubscriptions
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Returns an array of all your subscriptions.
```dart
final subscriptions = supabase.getSubscriptions();
```
## Examples
### Get all subscriptions
```dart
final subscriptions = supabase.getSubscriptions();
```
@@ -1,61 +0,0 @@
---
id: gt
title: '.gt()'
slug: /gt
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` is greater than the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.gt('country_id', 250)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.gt('country_id', 250)
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.gt('country_id', 250)
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.gt('country_id', 250)
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.gt('country_id', 250)
.execute();
```
@@ -1,61 +0,0 @@
---
id: gte
title: '.gte()'
slug: /gte
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` is greater than or equal to the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.gte('country_id', 250)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.gte('country_id', 250)
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.gte('country_id', 250)
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.gte('country_id', 250)
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.gte('country_id', 250)
.execute();
```
@@ -1,61 +0,0 @@
---
id: ilike
title: '.ilike()'
slug: /ilike
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value in the stated `column` matches the supplied `pattern` (case insensitive).
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.ilike('name', '%la%')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.ilike('name', '%la%')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.ilike('name', '%la%')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.ilike('name', '%la%')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.ilike('name', '%la%')
.execute();
```
@@ -1,63 +0,0 @@
---
id: in_
title: '.in_()'
slug: /in_
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` is found on the specified `values`.
`is_` and `in_` filter methods are suffixed with `_` to avoid collisions with reserved keywords.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.in_('name', ['Rio de Janeiro', 'San Francisco'])
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.in_('name', ['Rio de Janeiro', 'San Francisco'])
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.in_('name', ['Rio de Janeiro', 'San Francisco'])
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.in_('name', ['Rio de Janeiro', 'San Francisco'])
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.in_('name', ['Rio de Janeiro', 'San Francisco'])
.execute();
```
@@ -1,11 +0,0 @@
---
id: index
title: 'Getting started'
slug: getting-started
custom_edit_url: ../../spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Supabase Dart.
@@ -1,48 +0,0 @@
---
id: insert
title: 'Create data: insert()'
slug: /insert
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Performs an INSERT into the table.
```dart
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554}
]).execute();
```
## Notes
- By default, every time you run `insert()`, the client library will make a `select` to return the full record.
This is convenient, but it can also cause problems if your Policies are not configured to allow the `select` operation.
If you are using Row Level Security and you are encountering problems, try setting the `returning` param to `minimal`.
## Examples
### Create a record
```dart
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554}
]).execute();
```
### Bulk create
```dart
final res = await supabase
.from('cities')
.insert([
{'name': 'The Shire', 'country_id': 554},
{'name': 'Rohan', 'country_id': 555},
]).execute();
```
@@ -1,60 +0,0 @@
---
id: invoke
title: 'invoke()'
slug: /invoke
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Invokes a Supabase Function. See the [guide](/docs/guides/functions) for details on writing Functions.
```dart
final res = await supabaseClient.functions.invoke('hello', body: {'foo': 'baa'});
final data = res.data;
final error = res.error;
```
## Notes
- Requires an Authorization header.
- Invoke params generally match the [Fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) spec.
## Examples
### Basic invocation.
```dart
final res = await supabaseClient.functions.invoke('hello', body: {'foo': 'baa'});
final data = res.data;
final error = res.error;
```
### Specifying response type.
By default, `invoke()` will parse the response as JSON. You can parse the response in the following formats: `json`, `blob`, `text`, and `arrayBuffer`.
```dart
final res = await supabaseClient.functions.invoke(
'hello',
body: {'foo': 'baa'},
responseType: ResponseType.text,
);
final data = res.data;
final error = res.error;
```
### Parsing custom headers.
Any `headers` will be passed through to the function. A common pattern is to pass a logged-in user's JWT token as an Authorization header.
```dart
final res = await supabaseClient.functions.invoke(
'hello',
body: {'foo': 'baa'},
headers: {
'Authorization': 'Bearer ${supabase.auth.session()?.access_token}'
},
);
```
@@ -1,63 +0,0 @@
---
id: is_
title: '.is_()'
slug: /is_
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
A check for exact equality (null, true, false), finds all rows whose value on the stated `column` exactly match the specified `value`.
`is_` and `in_` filter methods are suffixed with `_` to avoid collisions with reserved keywords.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.is_('name', null)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.is_('name', null)
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.is_('name', null)
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.is_('name', null)
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.is_('name', null)
.execute();
```
@@ -1,107 +0,0 @@
---
id: like
title: '.like()'
slug: /like
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value in the stated `column` matches the supplied `pattern` (case sensitive).
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.like('name', '%la%')
.execute();
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
pattern
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The pattern to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.like('name', '%la%')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.like('name', '%la%')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.like('name', '%la%')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.like('name', '%la%')
.execute();
```
@@ -1,42 +0,0 @@
---
id: limit
title: 'limit()'
slug: /limit
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Limits the result with the specified count.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.limit(1)
.execute();
```
### With embedded resources
```dart
final res = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.limit(1, foreignTable: 'cities' )
.execute();
```
@@ -1,61 +0,0 @@
---
id: lt
title: '.lt()'
slug: /lt
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` is less than the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.lt('country_id', 250)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.lt('country_id', 250)
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.lt('country_id', 250)
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.lt('country_id', 250)
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.lt('country_id', 250)
.execute();
```
@@ -1,107 +0,0 @@
---
id: lte
title: '.lte()'
slug: /lte
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` is less than or equal to the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.lte('country_id', 250)
.execute();
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
column
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The column to filter on.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
value
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
The value to filter with.
</div>
</li>
</ul>
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.lte('country_id', 250)
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.lte('country_id', 250)
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.lte('country_id', 250)
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.lte('country_id', 250)
.execute();
```
@@ -1,61 +0,0 @@
---
id: match
title: '.match()'
slug: /match
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose columns match the specified `query` object.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.match({'name': 'Beijing', 'country_id': 156})
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.match({'name': 'Beijing', 'country_id': 156})
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.match({'name': 'Beijing', 'country_id': 156})
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.match({'name': 'Beijing', 'country_id': 156})
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.match({'name': 'Beijing', 'country_id': 156})
.execute();
```
@@ -1,61 +0,0 @@
---
id: neq
title: '.neq()'
slug: /neq
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose value on the stated `column` doesn't match the specified `value`.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.neq('name', 'The shire')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.neq('name', 'The shire')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.neq('name', 'San Francisco')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.neq('name', 'Mordor')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities')
.neq('name', 'Lagos')
.execute();
```
@@ -1,73 +0,0 @@
---
id: not
title: '.not()'
slug: /not
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows which doesn't satisfy the filter.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.not('name', 'eq', 'Paris')
.execute();
```
## Notes
- `.not()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter names and values.
```dart
.not('name','eq','Paris')
.not('arraycol','cs','{"a","b"}') // Use Postgres array {} for array column and 'cs' for contains.
.not('rangecol','cs','(1,2]') // Use Postgres range syntax for range column.
.not('id','in','(6,7)') // Use Postgres list () and 'in' for in_ filter.
.not('id','in','(${mylist.join(',')})') // You can insert a Dart list array.
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.not('name', 'eq', 'Paris')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Mordor' })
.not('name', 'eq', 'Paris')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('cities')
.delete()
.not('name', 'eq', 'Paris')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_cities)
.not('name', 'eq', 'Paris')
.execute();
```
@@ -1,51 +0,0 @@
---
id: or
title: '.or()'
slug: /or
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows satisfying at least one of the filters.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.or('id.eq.20,id.eq.30')
.execute();
```
## Notes
- `.or()` expects you to use the raw [PostgREST syntax](https://postgrest.org/en/stable/api.html#horizontal-filtering-rows) for the filter names and values.
```dart
.or('id.in.(6,7),arraycol.cs.{"a","b"}') // Use Postgres list () and 'in' for in_ filter. Array {} and 'cs' for contains.
.or('id.in.(${mylist.join(',')}),arraycol.cs.{${mylistArray.join(',')}}') // You can insert a Dart list for list or array column.
.or('id.in.(${mylist.join(',')}),rangecol.cs.(${mylistRange.join(',')}]') // You can insert a Dart list for list or range column.
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.or('id.eq.20,id.eq.30')
.execute();
```
### Use `or` with `and`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.or('id.gt.20,and(name.eq.New Zealand,name.eq.France)')
.execute();
```
@@ -1,42 +0,0 @@
---
id: order
title: 'order()'
slug: /order
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Orders the result with the specified column.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.order('id', ascending: false )
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.order('id', ascending: false )
.execute();
```
### With embedded resources
```dart
final res = await supabase
.from('countries')
.select('name, cities(name)')
.eq('name', 'United States')
.order('name', foreignTable: 'cities')
.execute();
```
@@ -1,59 +0,0 @@
---
id: overlaps
title: '.overlaps()'
slug: /overlaps
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, main_exports')
.overlaps('main_exports', ['computers', 'minerals'])
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.overlaps('main_exports', ['computers', 'minerals'])
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.overlaps('main_exports', ['computers', 'minerals'])
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.overlaps('main_exports', ['computers', 'minerals'])
.execute();
```
@@ -1,31 +0,0 @@
---
id: range
title: 'range()'
slug: /range
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Limits the result to rows within the specified range, inclusive.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.range(0,3)
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.range(0,3)
.execute();
```
@@ -1,59 +0,0 @@
---
id: rangeadjacent
title: '.rangeAdjacent()'
slug: /rangeadjacent
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeAdjacent('population_range_millions', '[70, 185]')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeAdjacent('population_range_millions', '[70, 185]')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.rangeAdjacent('population_range_millions', '[70, 185]')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.rangeAdjacent('population_range_millions', '[70, 185]')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.rangeAdjacent('population_range_millions', '[70, 185]')
.execute();
```
@@ -1,59 +0,0 @@
---
id: rangegt
title: '.rangeGt()'
slug: /rangegt
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGt('population_range_millions', '[150, 250]')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGt('population_range_millions', '[150, 250]')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.rangeGt('population_range_millions', '[150, 250]')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.rangeGt('population_range_millions', '[150, 250]')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.rangeGt('population_range_millions', '[150, 250]')
.execute();
```
@@ -1,59 +0,0 @@
---
id: rangegte
title: '.rangeGte()'
slug: /rangegte
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGte('population_range_millions', '[150, 250]')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeGte('population_range_millions', '[150, 250]')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.rangeGte('population_range_millions', '[150, 250]')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.rangeGte('population_range_millions', '[150, 250]')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.rangeGte('population_range_millions', '[150, 250]')
.execute();
```
@@ -1,59 +0,0 @@
---
id: rangelt
title: '.rangeLt()'
slug: /rangelt
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLt('population_range_millions', '[150, 250]')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLt('population_range_millions', '[150, 250]')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.rangeLt('population_range_millions', '[150, 250]')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.rangeLt('population_range_millions', '[150, 250]')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.rangeLt('population_range_millions', '[150, 250]')
.execute();
```
@@ -1,59 +0,0 @@
---
id: rangelte
title: '.rangeLte()'
slug: /rangelte
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLte('population_range_millions', '[150, 250]')
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('countries')
.select('name, id, population_range_millions')
.rangeLte('population_range_millions', '[150, 250]')
.execute();
```
### With `update()`
```dart
final res = await supabase
.from('countries')
.update({ 'name': 'Mordor' })
.rangeLte('population_range_millions', '[150, 250]')
.execute();
```
### With `delete()`
```dart
final res = await supabase
.from('countries')
.delete()
.rangeLte('population_range_millions', '[150, 250]')
.execute();
```
### With `rpc()`
```dart
// Only valid if the Stored Procedure returns a table type.
final res = await supabase
.rpc('echo_all_countries')
.rangeLte('population_range_millions', [150, 250])
.execute();
```
@@ -1,27 +0,0 @@
---
id: removesubscription
title: 'removeSubscription()'
slug: /removesubscription
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Removes an active subscription and returns the number of open connections.
```dart
supabase.removeSubscription(mySubscription);
```
## Notes
- Removing subscriptions is a great way to maintain the performance of your project's database. Supabase will automatically handle cleanup 30 seconds after a user is disconnected, but unused subscriptions may cause degradation as more users are simultaneously subscribed.
## Examples
### Remove a subscription
```dart
supabase.removeSubscription(mySubscription);
```
@@ -1,61 +0,0 @@
---
id: reset-password-email
title: 'Reset Password (Email)'
slug: /reset-password-email
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Sends a reset request to an email address.
```dart
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
final error = res.error;
```
## Notes
Sends a reset request to an email address.
When the user clicks the reset link in the email they will be forwarded to:
`<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=recovery`
Your app must detect `type=recovery` in the fragment and display a password reset form to the user.
You should then use the access_token in the url and new password to update the user as follows:
```dart
final res = await supabase.auth.api.updateUser(
accessToken,
UserAttributes(password: 'NEW_PASSWORD'),
);
```
## Examples
### Reset password
```dart
final res = await supabase.auth.api.resetPasswordForEmail('user@example.com');
final error = res.error;
```
### Reset password for Flutter
You can pass `redirectTo` to open the app via deeplink when user opens the password reset email.
```dart
final res = await supabase.auth.api.resetPasswordForEmail(
'user@example.com',
options: AuthOptions(redirectTo: kIsWeb
? null
: 'io.supabase.flutter://reset-callback/'),
);
final error = res.error;
```
@@ -1,51 +0,0 @@
---
id: rpc
title: 'Stored Procedures: rpc()'
slug: /rpc
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
You can call stored procedures as a "Remote Procedure Call".
That's a fancy way of saying that you can put some logic into your database then call it from anywhere.
It's especially useful when the logic rarely changes - like password resets and updates.
```dart
final res = await supabase
.rpc('hello_world')
.execute();
```
## Examples
### Call a stored procedure
This is an example invoking a stored procedure.
```dart
final res = await supabase
.rpc('hello_world')
.execute();
```
### With Parameters
```dart
final res = await supabase
.rpc('echo_city', params: { 'name': 'The Shire' })
.execute();
```
### With count option
You can specify a count option to get the row count along with your data.
Allowed values for count option are `exact`, `planned` and `estimated`.
```dart
final res = await supabase
.rpc('hello_world')
.execute(count: CountOption.exact);
```
@@ -1,147 +0,0 @@
---
id: select
title: 'Fetch data: select()'
slug: /select
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Performs vertical filtering with SELECT.
```dart
final res = await supabase
.from('cities')
.select()
.execute();
final data = res.data;
final error = res.error;
```
## Notes
- By default, Supabase projects will return a maximum of 1,000 rows. This setting can be changed in Project API Settings. It's recommended that you keep it low to limit the payload size of accidental or malicious requests. You can use `range()` queries to paginate through your data.
- `select()` can be combined with [Modifiers](/docs/reference/dart/using-modifiers)
- `select()` can be combined with [Filters](/docs/reference/dart/using-filters)
- If using the Supabase hosted platform `apikey` is technically a reserved keyword, since the API gateway will pluck it out for authentication. [It should be avoided as a column name](https://github.com/supabase/supabase/issues/5465).
## Examples
### Getting your data
```dart
final res = await supabase
.from('cities')
.select()
.execute();
final data = res.data;
final error = res.error;
```
### Selecting specific columns
You can select specific fields from your tables.
```dart
final res = await supabase
.from('cities')
.select('name')
.execute();
```
### Query foreign tables
If your database has relationships, you can query related tables too.
```dart
final res = await supabase
.from('countries')
.select('''
name,
cities (
name
)
''')
.execute();
```
### Query the same foreign table multiple times
Sometimes you will need to query the same foreign table twice.
In this case, you can use the name of the joined column to identify
which join you intend to use. For convenience, you can also give an
alias for each column. For example, if we had a shop of products,
and we wanted to get the supplier and the purchaser at the same time
(both in the users) table:
```dart
final res = await supabase
.from('products')
.select('''
id,
supplier:supplier_id ( name ),
purchaser:purchaser_id ( name )
''')
.execute();
```
### Filtering with inner joins
If you want to filter a table based on a child table's values you can use the `!inner()` function. For example, if you wanted
to select all rows in a `message` table which belong to a user with the `username` "Jane":
```dart
final res = await supabase
.from('messages')
.select('*, users!inner(*)')
.eq('users.username', 'Jane')
.execute();
```
### Querying with count option
You can get the number of rows by using the count option.
Allowed values for count option are [exact](https://postgrest.org/en/stable/api.html#exact-count), [planned](https://postgrest.org/en/stable/api.html#planned-count) and [estimated](https://postgrest.org/en/stable/api.html#estimated-count).
```dart
final res = await supabase
.from('cities')
.select('name')
.execute(count: CountOption.exact);
final count = res.count;
```
### Querying JSON data
If you have data inside of a JSONB column, you can apply select
and query filters to the data values. Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for querying JSON data. Also see
[PostgREST docs](http://postgrest.org/en/v7.0.0/api.html#json-columns) for more details.
```dart
final res = await supabase
.from('users')
.select('''
id, name,
address->street
''')
.eq('address->postcode', 90210)
.execute();
```
### Return data as CSV
By default the data is returned in JSON format, however you can also request for it to be returned as Comma Separated Values.
```dart
final res = await supabase
.from('users')
.select()
.csv()
.execute();
```
@@ -1,31 +0,0 @@
---
id: single
title: 'single()'
slug: /single
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Retrieves only one row from the result. Result must be one row (e.g. using limit), otherwise this will result in an error.
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.single()
.execute();
```
## Examples
### With `select()`
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.single()
.execute();
```
@@ -1,33 +0,0 @@
---
id: storage-createbucket
title: 'createBucket()'
slug: /storage-createbucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Creates a new Storage bucket
```dart
final res = await supabase
.storage
.createBucket('avatars');
```
## Notes
- Policy permissions required:
- `buckets` permissions: `insert`
- `objects` permissions: none
## Examples
### Create bucket
```dart
final res = await supabase
.storage
.createBucket('avatars');
```
@@ -1,33 +0,0 @@
---
id: storage-deletebucket
title: 'deleteBucket()'
slug: /storage-deletebucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Deletes an existing bucket. A bucket can't be deleted with existing objects inside it. You must first `empty()` the bucket.
```dart
final res = await supabase
.storage
.deleteBucket('avatars');
```
## Notes
- Policy permissions required:
- `buckets` permissions: `select` and `delete`
- `objects` permissions: none
## Examples
### Delete bucket
```dart
final res = await supabase
.storage
.deleteBucket('avatars');
```
@@ -1,33 +0,0 @@
---
id: storage-emptybucket
title: 'emptyBucket()'
slug: /storage-emptybucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Removes all objects inside a single bucket.
```dart
final res = await supabase
.storage
.emptyBucket('avatars');
```
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: `select` and `delete`
## Examples
### Empty bucket
```dart
final res = await supabase
.storage
.emptyBucket('avatars');
```
@@ -1,39 +0,0 @@
---
id: storage-from-createsignedurl
title: 'from.createSignedUrl()'
slug: /storage-from-createsignedurl
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Create signed url to download file without requiring permissions. This URL can be valid for a set number of seconds.
```dart
final res = await supabase
.storage
.from('avatars')
.createSignedUrl('avatar1.png', 60);
final signedURL = res.data;
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### Create Signed URL
```dart
final res = await supabase
.storage
.from('avatars')
.createSignedUrl('avatar1.png', 60);
final signedURL = res.data;
```
@@ -1,35 +0,0 @@
---
id: storage-from-download
title: 'from.download()'
slug: /storage-from-download
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Downloads a file.
```dart
final res = await supabase
.storage
.from('avatars')
.download('avatar1.png');
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### Download file
```dart
final res = await supabase
.storage
.from('avatars')
.download('avatar1.png');
```
@@ -1,40 +0,0 @@
---
id: storage-from-getpublicurl
title: 'from.getPublicUrl()'
slug: /storage-from-getpublicurl
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Retrieve URLs for assets in public buckets
```dart
final res = supabase
.storage
.from('public-bucket')
.getPublicUrl('avatar1.png');
final publicURL = res.data;
```
## Notes
- The bucket needs to be set to public, either via [updateBucket()](/docs/reference/javascript/storage-updatebucket) or by going to Storage on [app.supabase.com](https://app.supabase.com), clicking the overflow menu on a bucket and choosing "Make public"
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: none
## Examples
### Returns the URL for an asset in a public bucket
```dart
final res = supabase
.storage
.from('public-bucket')
.getPublicUrl('avatar1.png');
final publicURL = res.data;
```
@@ -1,35 +0,0 @@
---
id: storage-from-list
title: 'from.list()'
slug: /storage-from-list
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Lists all the files within a bucket.
```dart
final res = await supabase
.storage
.from('avatars')
.list();
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `select`
## Examples
### List files in a bucket
```dart
final res = await supabase
.storage
.from('avatars')
.list();
```
@@ -1,35 +0,0 @@
---
id: storage-from-move
title: 'from.move()'
slug: /storage-from-move
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Moves an existing file, optionally renaming it at the same time.
```dart
final res = await supabase
.storage
.from('avatars')
.move('public/avatar1.png', 'private/avatar2.png');
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
## Examples
### Move file
```dart
final res = await supabase
.storage
.from('avatars')
.move('public/avatar1.png', 'private/avatar2.png');
```
@@ -1,35 +0,0 @@
---
id: storage-from-remove
title: 'from.remove()'
slug: /storage-from-remove
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Deletes files within the same bucket
```dart
final res = await supabase
.storage
.from('avatars')
.remove(['avatar1.png']);
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `delete` and `select`
## Examples
### Delete file
```dart
final res = await supabase
.storage
.from('avatars')
.remove(['avatar1.png']);
```
@@ -1,43 +0,0 @@
---
id: storage-from-update
title: 'from.update()'
slug: /storage-from-update
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Replaces an existing file at the specified path with a new one.
```dart
final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));
```
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `update` and `select`
## Examples
### Update file
```dart
final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.update('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));
```
@@ -1,112 +0,0 @@
---
id: storage-from-upload
title: 'from.upload()'
slug: /storage-from-upload
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Uploads a file to an existing bucket.
```dart
final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
path
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The relative file path. Should be of the format `folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileBody
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>ArrayBuffer</code> | <code>ArrayBufferView</code> | <code>Blob</code> | <code>Buffer</code> | <code>File</code> | <code>FormData</code> | <code>ReadableStream</code> | <code>ReadableStream</code> | <code>URLSearchParams</code> | <code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The body of the file to be stored in the bucket.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
fileOptions
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>FileOptions</code>
</span>
</h4>
<div class="method-list-item-description">
HTTP headers.
`cacheControl`: string, the `Cache-Control: max-age=<seconds>` seconds value.
`contentType`: string, the `Content-Type` header value. Should be specified if using a `fileBody` that is neither `Blob` nor `File` nor `FormData`, otherwise will default to `text/plain;charset=UTF-8`.
`upsert`: boolean, whether to perform an upsert.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: none
- `objects` permissions: `insert`
## Examples
### Upload file
```dart
final avatarFile = File('path/to/file');
final res = await supabase
.storage
.from('avatars')
.upload('public/avatar1.png', avatarFile, fileOptions: FileOptions(
cacheControl: '3600',
upsert: false
));
```
@@ -1,59 +0,0 @@
---
id: storage-getbucket
title: 'getBucket()'
slug: /storage-getbucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Retrieves the details of an existing Storage bucket.
```dart
final res = await supabase
.storage
.getBucket('avatars')
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The unique identifier of the bucket you would like to retrieve.
</div>
</li>
</ul>
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: none
## Examples
### Get bucket
```dart
final res = await supabase
.storage
.getBucket('avatars')
```
@@ -1,33 +0,0 @@
---
id: storage-listbuckets
title: 'listBuckets()'
slug: /storage-listbuckets
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Retrieves the details of all Storage buckets within an existing product.
```dart
final res = await supabase
.storage
.listBuckets()
```
## Notes
- Policy permissions required:
- `buckets` permissions: `select`
- `objects` permissions: none
## Examples
### List buckets
```dart
final res = await supabase
.storage
.listBuckets()
```
@@ -1,33 +0,0 @@
---
id: storage-updatebucket
title: 'updateBucket()'
slug: /storage-updatebucket
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Updates a new Storage bucket
```dart
final res = await supabase
.storage
.updateBucket('avatars', { public: false });
```
## Notes
- Policy permissions required:
- `buckets` permissions: `update`
- `objects` permissions: none
## Examples
### Update bucket
```dart
final res = await supabase
.storage
.updateBucket('avatars', { public: false });
```
@@ -1,67 +0,0 @@
---
id: stream
title: 'stream()'
slug: /stream
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Notifies of data at the queried table.
```dart
supabase
.from('countries')
.stream(['id'])
.execute();
```
## Notes
- `stream()` will emit the initial data as well as any further change on the database as `Stream` of `List<Map<String, dynamic>>` by combining Postgrest and Realtime.
- Takes a list of primary key columns as its argument.
## Examples
### Listening to a specific table
```dart
supabase
.from('countries')
.stream(['id'])
.execute();
```
### Listening to a specific rows within a table
You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
This syntax is the as how you can filter data in Realtime
```dart
supabase
.from('countries:id=eq.120')
.stream(['id'])
.execute();
```
### With `order()`
```dart
supabase
.from('countries')
.stream(['id'])
.order('name', ascending: false)
.execute();
```
### With `limit()`
```dart
supabase
.from('countries')
.stream(['id'])
.order('name', ascending: false)
.limit(10)
.execute();
```
@@ -1,119 +0,0 @@
---
id: subscribe
title: 'on().subscribe()'
slug: /subscribe
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Subscribe to realtime changes in your database.
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.all, (payload) {
// Handle realtime payload
})
.subscribe();
```
## Notes
- Realtime is disabled by default for new Projects for better database performance and security. You can turn it on by [managing replication](/docs/guides/api#managing-realtime).
- If you want to receive the "previous" data for updates and deletes, you will need to set `REPLICA IDENTITY` to `FULL`, like this: `ALTER TABLE your_table REPLICA IDENTITY FULL;`
## Examples
### Listen to all database changes
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.all, (payload) {
// Handle realtime payload
})
.subscribe();
```
### Listening to a specific table
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.all, (payload) {
// Handle realtime payload
})
.subscribe();
```
### Listening to inserts
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.insert, (payload) {
// Handle realtime payload
})
.subscribe();
```
### Listening to updates
By default, Supabase will send only the updated record. If you want to receive the previous values as well you can
enable full replication for the table you are listening too:
```sql
alter table "your_table" replica identity full;
```
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.update, (payload) {
// Handle realtime payload
})
.subscribe();
```
### Listening to deletes
By default, Supabase does not send deleted records. If you want to receive the deleted record you can
enable full replication for the table you are listening too:
```sql
alter table "your_table" replica identity full;
```
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.delete, (payload) {
// Handle realtime payload
})
.subscribe();
```
### Listening to multiple events
You can chain listeners if you want to listen to multiple events for each table.
```dart
final mySubscription = supabase
.from('countries')
.on(SupabaseEventTypes.insert, handleInsert)
.on(SupabaseEventTypes.delete, handleDelete)
.subscribe();
```
### Listening to row level changes
You can listen to individual rows using the format `{table}:{col}=eq.{val}` - where `{col}` is the column name, and `{val}` is the value which you want to match.
```dart
final mySubscription = supabase
.from('countries:id=eq.200')
.on(SupabaseEventTypes.update, handleRecordUpdated)
.subscribe();
```
@@ -1,77 +0,0 @@
---
id: textsearch
title: '.textSearch()'
slug: /textsearch
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Finds all rows whose tsvector value on the stated `column` matches to_tsquery(query).
## Examples
### Text search
```dart
final res = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', "'fat' & 'cat'",
config: 'english'
)
.execute();
```
### Basic normalization
Uses PostgreSQL's `plainto_tsquery` function.
```dart
final res = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', "'fat' & 'cat'",
type: TextSearchType.plain,
config: 'english'
)
.execute();
```
### Full normalization
Uses PostgreSQL's `phraseto_tsquery` function.
```dart
final res = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', "'fat' & 'cat'",
type: TextSearchType.phrase,
config: 'english'
)
.execute();
```
### Full normalization
Uses PostgreSQL's `websearch_to_tsquery` function.
This function will never raise syntax errors, which makes it possible to use raw user-supplied input for search, and can be used
with advanced operators.
- `unquoted text`: text not inside quote marks will be converted to terms separated by & operators, as if processed by plainto_tsquery.
- `"quoted text"`: text inside quote marks will be converted to terms separated by <-> operators, as if processed by phraseto_tsquery.
- `OR`: the word “or” will be converted to the | operator.
- `-`: a dash will be converted to the ! operator.
```dart
final res = await supabase
.from('quotes')
.select('catchphrase')
.textSearch('catchphrase', "'fat or cat'",
type: TextSearchType.websearch,
config: 'english'
)
.execute();
```
@@ -1,55 +0,0 @@
---
id: update
title: 'Modify data: update()'
slug: /update
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Performs an UPDATE on the table.
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Middle Earth' })
.match({ 'name': 'Auckland' })
.execute();
```
## Notes
- `update()` should always be combined with [Filters](/docs/reference/dart/using-filters) to target the item(s) you wish to update.
## Examples
### Updating your data
```dart
final res = await supabase
.from('cities')
.update({ 'name': 'Middle Earth' })
.match({ 'name': 'Auckland' })
.execute();
```
### Updating JSON data
Postgres offers a
[number of operators](https://www.postgresql.org/docs/current/functions-json.html)
for working with JSON data. Right now it is only possible to update an entire JSON document,
but we are [working on ideas](https://github.com/PostgREST/postgrest/issues/465) for updating individual keys.
```dart
final res = await supabase
.from('users')
.update({
'address': {
'street': 'Melrose Place',
'postcode': 90210
}
})
.eq('address->postcode', 90210)
.execute();
```
@@ -1,62 +0,0 @@
---
id: upsert
title: 'Upsert data: upsert()'
slug: /upsert
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Performs an UPSERT into the table.
```dart
final res = await supabase
.from('messages')
.upsert({ 'id': 3, 'message': 'foo', 'username': 'supabot' })
.execute();
```
## Notes
- Primary keys should be included in the data payload in order for an update to work correctly.
- Primary keys must be natural, not surrogate. There are however, [workarounds](https://github.com/PostgREST/postgrest/issues/1118) for surrogate primary keys.
## Examples
### Upsert your data
```dart
final res = await supabase
.from('messages')
.upsert({ 'id': 3, 'message': 'foo', 'username': 'supabot' })
.execute();
```
### Upserting into tables with constraints
Running the following will cause supabase to upsert data into the `users` table.
If the username 'supabot' already exists, the `onConflict` argument tells supabase to overwrite that row
based on the column passed into `onConflict`.
```dart
final res = await supabase
.from('users')
.upsert({ 'username': 'supabot' }, { 'onConflict': 'username' })
.execute();
```
### Return the exact number of rows
Allowed values for count option are `exact`, `planned` and `estimated`.
```dart
final res = await supabase
.from('users')
.upsert({
'id': 3,
'message': 'foo',
'username': 'supabot'
})
.execute(count: CountOption.exact);
```
@@ -1,44 +0,0 @@
---
id: using-filters
title: 'Using Filters'
slug: /using-filters
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Filters can be used on `select()`, `update()`, and `delete()` queries.
If a Stored Procedure returns a table response, you can also apply filters.
### Applying Filters
You must apply your filters to the end of your query. For example:
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.eq('name', 'The Shire') // Correct
.execute();
final res = await supabase
.from('cities')
.eq('name', 'The Shire') // Incorrect
.select('name, country_id')
.execute();
```
### Chaining
Filters can be chained together to produce advanced queries. For example:
```dart
final res = await supabase
.from('cities')
.select('name, country_id')
.gte('population', 1000)
.lt('population', 10000)
.execute();
```
@@ -1,13 +0,0 @@
---
id: using-modifiers
title: 'Using Modifiers'
slug: /using-modifiers
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Modifiers can be used on `select()` queries.
If a Stored Procedure returns a table response, you can also apply modifiers to the `rpc()` function.
@@ -1,8 +1,7 @@
---
id: initializing
title: 'Initializing'
slug: /initializing
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
slug: initializing
---
import Tabs from '@theme/Tabs'
@@ -21,13 +20,13 @@ For `supabase_flutter`, you will be using the static `initialize()` method on `S
## Examples
### Dart SupabaseClient()
### Dart `SupabaseClient()`
```dart
final supabase = SupabaseClient('https://xyzcompany.supabase.co', 'public-anon-key');
```
### Flutter initialize()
### Flutter `initialize()`
```dart title="main.dart"
Future<void> main() async {
@@ -1,8 +1,7 @@
---
id: installing
title: 'Installing'
slug: /installing
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_dart_v1_legacy.yml
slug: installing
---
import Tabs from '@theme/Tabs'
+9 -1
View File
@@ -6,6 +6,14 @@ sidebar_label: Supabase Dart Library
# Supabase Dart Library
:::note
You're viewing the Supabase docs for a developer preview version.
Refer to the `v0` docs for the previous release.
:::
This reference documents every object and method available in Supabase's isomorphic Dart library, `supabase-dart`.
You can use the `supabase-dart` library to:
@@ -19,4 +27,4 @@ You can use the `supabase-dart` library to:
## Additional Links
- Source Code: [github.com/supabase/supabase-dart](https://github.com/supabase/supabase-dart)
- [Known bugs and issues](https://github.com/supabase/supabase-dart/issues)
- [Known bugs and issues](https://github.com/supabase/supabase-flutter/issues)
@@ -0,0 +1,22 @@
---
id: intro
slug: /
sidebar_label: Supabase Dart Library
---
# Supabase Dart Library
This reference documents every object and method available in Supabase's isomorphic Dart library, `supabase-dart`.
You can use the `supabase-dart` library to:
- interact with your Postgres database
- listen to database changes
- invoke Deno Edge Functions
- build login and user management functionality
- manage large files
## Additional Links
- Source Code: [github.com/supabase/supabase-dart](https://github.com/supabase/supabase-dart)
- [Known bugs and issues](https://github.com/supabase/supabase-dart/issues)
@@ -0,0 +1,120 @@
{
"sidebar": [
{
"type": "category",
"label": "Getting Started",
"items": ["intro", "generated/installing", "generated/initializing"],
"collapsed": true
},
{
"type": "category",
"label": "Auth",
"items": [
"generated/auth-signup",
"generated/auth-signin",
"generated/auth-signinwithprovider",
"generated/auth-signout",
"generated/auth-session",
"generated/auth-user",
"generated/auth-update",
"generated/auth-onauthstatechange",
"generated/reset-password-email"
],
"collapsed": true
},
{
"type": "category",
"label": "Functions",
"items": ["generated/invoke"],
"collapsed": true
},
{
"type": "category",
"label": "Database",
"items": [
"generated/select",
"generated/insert",
"generated/update",
"generated/upsert",
"generated/delete",
"generated/rpc"
],
"collapsed": true
},
{
"type": "category",
"label": "Realtime",
"items": [
"generated/subscribe",
"generated/removesubscription",
"generated/getsubscriptions",
"generated/stream"
],
"collapsed": true
},
{
"type": "category",
"label": "Storage",
"items": [
"generated/storage-createbucket",
"generated/storage-getbucket",
"generated/storage-listbuckets",
"generated/storage-updatebucket",
"generated/storage-deletebucket",
"generated/storage-emptybucket",
"generated/storage-from-upload",
"generated/storage-from-download",
"generated/storage-from-list",
"generated/storage-from-update",
"generated/storage-from-move",
"generated/storage-from-remove",
"generated/storage-from-createsignedurl",
"generated/storage-from-getpublicurl"
],
"collapsed": true
},
{
"type": "category",
"label": "Modifiers",
"items": [
"generated/using-modifiers",
"generated/limit",
"generated/order",
"generated/range",
"generated/single"
],
"collapsed": true
},
{
"type": "category",
"label": "Filters",
"items": [
"generated/using-filters",
"generated/or",
"generated/not",
"generated/match",
"generated/eq",
"generated/neq",
"generated/gt",
"generated/gte",
"generated/lt",
"generated/lte",
"generated/like",
"generated/ilike",
"generated/is_",
"generated/in_",
"generated/contains",
"generated/containedby",
"generated/rangelt",
"generated/rangegt",
"generated/rangegte",
"generated/rangelte",
"generated/rangeadjacent",
"generated/overlaps",
"generated/textsearch",
"generated/filter"
],
"collapsed": true
}
]
}
+1 -1
View File
@@ -1 +1 @@
[]
["v0"]
@@ -1,263 +0,0 @@
---
id: auth-admin-createuser
title: 'createUser()'
slug: /auth-admin-createuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Creates a new user.
This function should only be called on a server. Never expose your `service_role` key in the browser.
```js
const { data, error } = await supabase.auth.admin.createUser({
email: 'user@email.com',
password: 'password',
user_metadata: { name: 'Yoda' },
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
AdminUserAttributes
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
app_metadata
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.
Only a service role can modify.
The `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other
access control information.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
The `data` should be a JSON object that includes user-specific info, such as their first and last name.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email_confirm
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
Confirms the user's email address if set to true.
Only a service role can modify.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
password
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's password.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's phone.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone_confirm
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
Confirms the user's phone number if set to true.
Only a service role can modify.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
user_metadata
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
Only a service role can modify.
The `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.
Note: When using the GoTrueAdminApi and wanting to modify a user's metadata,
this attribute is used instead of UserAttributes data.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- To confirm the user's email address or phone number, set `email_confirm` or `phone_confirm` to true. Both arguments default to false.
## Examples
### Create a new user with custom user metadata
```js
const { data, error } = await supabase.auth.admin.createUser({
email: 'user@email.com',
password: 'password',
user_metadata: { name: 'Yoda' },
})
```
### Auto-confirm the user's email
```js
const { data, error } = await supabase.auth.admin.createUser({
email: 'user@email.com',
email_confirm: true,
})
```
### Auto-confirm the user's phone number
```js
const { data, error } = await supabase.auth.admin.createUser({
phone: '1234567890',
phone_confirm: true,
})
```
@@ -1,59 +0,0 @@
---
id: auth-admin-deleteuser
title: 'deleteUser()'
slug: /auth-admin-deleteuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Delete a user. Requires a `service_role` key.
```js
const { data, error } = await supabase.auth.admin.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0'
)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
id
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user id you want to remove.
This function should only be called on a server. Never expose your `service_role` key in the browser.
</div>
</li>
</ul>
## Notes
- The `deleteUser()` method requires the user's ID, which maps to the `auth.users.id` column.
## Examples
### Removes a user
```js
const { data, error } = await supabase.auth.admin.deleteUser(
'715ed5db-f090-4b8c-a067-640ecee36aa0'
)
```
@@ -1,155 +0,0 @@
---
id: auth-admin-generatelink
title: 'generateLink()'
slug: /auth-admin-generatelink
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Generates email links and OTPs to be sent via a custom email provider.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'signup',
{
'password': 'secret'
}
)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateLinkParams
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>GenerateSignupLinkParams</code> | <code>GenerateInviteOrMagiclinkParams</code> | <code>GenerateRecoveryLinkParams</code> | <code>GenerateEmailChangeLinkParams</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateSignupLinkParams
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateRecoveryLinkParams
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateInviteOrMagiclinkParams
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
GenerateEmailChangeLinkParams
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### Generate a signup link.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'signup',
{
'password': 'secret'
}
)
```
### Generate an invite link.
```js
const { data, error } = await supabase.auth.admin.generateLink(
'email@example.com'
'invite',
)
```
@@ -1,56 +0,0 @@
---
id: auth-admin-getuserbyid
title: 'getUserById()'
slug: /auth-admin-getuserbyid
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Get user by id.
```js
const { data, error } = await supabase.auth.admin.getUserById(1)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
uid
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's unique identifier
This function should only be called on a server. Never expose your `service_role` key in the browser.
</div>
</li>
</ul>
## Notes
- Fetches the user object from the database based on the user's id.
- The `getUserById()` method requires the user's id which maps to the `auth.users.id` column.
## Examples
### Fetch the user object using the access_token jwt.
```js
const { data, error } = await supabase.auth.admin.getUserById(1)
```
@@ -1,122 +0,0 @@
---
id: auth-admin-inviteuserbyemail
title: 'inviteUserByEmail()'
slug: /auth-admin-inviteuserbyemail
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Sends an invite link to an email address.
```js
const { data, error } = await supabase.auth.admin.inviteUserByEmail(
'email@example.com'
)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The email address of the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
Optional user metadata
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A URL or mobile deeplink to send the user to after they are confirmed.
</div>
</li>
</ul>
</li>
</ul>
## Notes
- Sends an invite link to the user's email address.
## Examples
### Invite a user
```js
const { data, error } = await supabase.auth.admin.inviteUserByEmail(
'email@example.com'
)
```
@@ -1,31 +0,0 @@
---
id: auth-admin-listusers
title: 'listUsers()'
slug: /auth-admin-listusers
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Get a list of users.
This function should only be called on a server. Never expose your `service_role` key in the browser.
```js
const {
data: { users },
error,
} = await supabase.auth.admin.listUsers()
```
## Examples
### Get a full list of users.
```js
const {
data: { users },
error,
} = await supabase.auth.admin.listUsers()
```
@@ -1,303 +0,0 @@
---
id: auth-admin-updateuserbyid
title: 'updateUserById()'
slug: /auth-admin-updateuserbyid
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Updates the user data.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ user_metadata: { hello: 'world' } }
)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
uid
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
AdminUserAttributes
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
app_metadata
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.
Only a service role can modify.
The `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other
access control information.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
data
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
The `data` should be a JSON object that includes user-specific info, such as their first and last name.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email_confirm
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
Confirms the user's email address if set to true.
Only a service role can modify.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
password
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's password.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's phone.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone_confirm
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
Confirms the user's phone number if set to true.
Only a service role can modify.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
user_metadata
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
Only a service role can modify.
The `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.
Note: When using the GoTrueAdminApi and wanting to modify a user's metadata,
this attribute is used instead of UserAttributes data.
</div>
</li>
</ul>
</li>
</ul>
## Examples
### Updates a user's email.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ email: 'new@email.com' }
)
```
### Updates a user's password.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ password: 'new_password' }
)
```
### Updates a user's metadata.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ user_metadata: { hello: 'world' } }
)
```
### Updates a user's app_metadata.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ app_metadata: { plan: 'trial' } }
)
```
### Confirms a user's email address.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ email_confirm: true }
)
```
### Confirms a user's phone number.
```js
const { data: user, error } = await supabase.auth.admin.updateUserById(
'6aa5d0d4-2a9f-4483-b6c8-0cf4c6c98ac4',
{ phone_confirm: true }
)
```
@@ -1,24 +0,0 @@
---
id: auth-getsession
title: 'getSession()'
slug: /auth-getsession
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Returns the session, refreshing it if necessary.
The session returned can be null if the session is not detected which can happen in the event a user is not signed-in or has logged out.
```js
const { data, error } = await supabase.auth.getSession()
```
## Examples
### Get the session data
```js
const { data, error } = await supabase.auth.getSession()
```
@@ -1,66 +0,0 @@
---
id: auth-getuser
title: 'getUser()'
slug: /auth-getuser
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Gets the current user details if there is an existing session.
```js
const {
data: { user },
} = await supabase.auth.getUser()
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
jwt
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Takes in an optional access token jwt. If no jwt is provided, getUser() will attempt to get the jwt from the current session.
</div>
</li>
</ul>
## Notes
- This method gets the user object from the current session.
- Fetches the user object from the database instead of local session.
## Examples
### Get the logged in user with the current existing session
```js
const {
data: { user },
} = await supabase.auth.getUser()
```
### Get the logged in user with a custom access token jwt.
```js
const {
data: { user },
} = await supabase.auth.getUser(jwt)
```
@@ -1,105 +0,0 @@
---
id: auth-onauthstatechange
title: 'onAuthStateChange()'
slug: /auth-onauthstatechange
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Receive a notification every time an auth event happens.
```js
supabase.auth.onAuthStateChange((event, session) => {
console.log(event, session)
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
callback
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
A callback function to be invoked when an auth event happens.
</div>
</li>
</ul>
## Notes
- Types of auth events: `SIGNED_IN`, `SIGNED_OUT`, `TOKEN_REFRESHED`, `USER_UPDATED`, `USER_DELETED`, `PASSWORD_RECOVERY`
## Examples
### Listen to auth changes
```js
supabase.auth.onAuthStateChange((event, session) => {
console.log(event, session)
})
```
### Listen to sign in
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'SIGNED_IN') console.log('SIGNED_IN', session)
})
```
### Listen to sign out
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'SIGNED_OUT') console.log('SIGNED_OUT', session)
})
```
### Listen to token refresh
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'TOKEN_REFRESHED') console.log('TOKEN_REFRESHED', session)
})
```
### Listen to user updates
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'USER_UPDATED') console.log('USER_UPDATED', session)
})
```
### Listen to user deleted
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'USER_DELETED') console.log('USER_DELETED', session)
})
```
### Listen to password recovery events
```js
supabase.auth.onAuthStateChange((event, session) => {
if (event == 'PASSWORD_RECOVERY') console.log('PASSWORD_RECOVERY', session)
})
```
@@ -1,136 +0,0 @@
---
id: auth-resetpasswordforemail
title: 'resetPasswordForEmail()'
slug: /auth-resetpasswordforemail
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Sends a password reset request to an email address.
```js
const { error, data } = await supabase.auth.resetPasswordForEmail(email, options: {
redirectTo: 'https://example.com/update-password',
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The email address of the user.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
captchaToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Verification token received when the user completes the captcha on the site.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The URL to send the user to after they click the password reset link.
</div>
</li>
</ul>
</li>
</ul>
## Notes
Sends a password reset request to an email address.
When the user clicks the password reset link in the email, they are redirected to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url) by default. You can modify your `SITE_URL` or add additional redirect URLs in [your project](https://app.supabase.com/project/_/auth/settings).
`<SITE_URL>#access_token=x&refresh_token=y&expires_in=z&token_type=bearer&type=recovery`
Your app must detect `type=recovery` in the fragment and display a password reset form to the user.
You should then [update the user](/docs/reference/javascript/next/auth-updateuser) as follows:
```js
const { error, data } = await supabase.auth.updateUser({
password: new_password,
})
```
## Examples
### Reset password
```js
const { error, data } = await supabase.auth.resetPasswordForEmail(email, options: {
redirectTo: 'https://example.com/update-password',
})
```
@@ -1,58 +0,0 @@
---
id: auth-setsession
title: 'setSession()'
slug: /auth-setsession
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Sets the session data from refresh token and returns current session or an error if the refresh token is invalid.
```js
const { data, error } = supabase.auth.setSession(refresh_token)
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
refresh_token
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A refresh token returned by supabase auth.
</div>
</li>
</ul>
## Notes
- `setSession()` takes in a refresh token and uses it to get a new session.
- The refresh token can only be used once to obtain a new session.
- Refresh token rotation (see [`REFRESH_TOKEN_ROTATION_ENABLED`](https://supabase.com/docs/reference/auth/config#refresh_token_rotation_enabled)) is enabled by default on all projects to guard against replay attacks.
- You can configure the [`REFRESH_TOKEN_REUSE_INTERVAL`](https://supabase.com/docs/reference/auth/config#refresh_token_reuse_interval) which provides a short window in which the same refresh token can be used multiple times in the event of concurrency or offline issues.
## Examples
### Refresh the session
Sets the session data from refresh_token and returns current session or an error if the refresh_token is invalid.
```js
const { data, error } = supabase.auth.setSession(refresh_token)
```
@@ -1,197 +0,0 @@
---
id: auth-signinwithoauth
title: 'signInWithOAuth()'
slug: /auth-signinwithoauth
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Log in an existing user via a third-party provider.
```js
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github',
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
SignInWithOAuthCredentials
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
provider
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>Provider</code>
</span>
</h4>
<div class="method-list-item-description">
One of the providers supported by GoTrue.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
queryParams
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
An object of query params
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
redirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A URL to send the user to after they are confirmed.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
scopes
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
A space-separated list of scopes granted to the OAuth application.
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
## Notes
- This method is used for signing in using a third-party provider.
- Supabase supports many different [third-party providers](https://supabase.com/docs/guides/auth#providers).
## Examples
### Sign in using a third-party provider
```js
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github',
})
```
### Sign in using a third-party provider with redirect
When the third-party provider successfully authenticates the user, the provider will redirect the user to the URL specified in the `redirectTo` parameter. This parameter defaults to the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). It does not redirect the user immediately after invoking this method.
You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
```js
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github'
options: {
redirectTo: 'https://example.com/welcome'
}
}
```
### Sign in with scopes
If you need additional data from an OAuth provider, you can include a space-separated list of scopes in your request to get back an OAuth provider token.
You may also need to specify the scopes in the provider's OAuth app settings, depending on the provider. The list of scopes will be documented by the third-party provider you are using and specifying scopes will enable you to use the OAuth provider token to call additional APIs supported by the third-party provider to get more information.
```js
const { data, error } = await supabase.auth.signInWithOAuth({
provider: 'github'
options: {
scopes: 'repo gist notifications'
}
})
const oAuthToken = data.session.provider_token // use to access provider API
```
@@ -1,321 +0,0 @@
---
id: auth-signinwithotp
title: 'signInWithOtp()'
slug: /auth-signinwithotp
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Log in a user using magiclink or a one-time password (OTP).
If the `{{ .ConfirmationURL }}` variable is specified in the email template, a magiclink will be sent.
If the `{{ .Token }}` variable is specified in the email template, an OTP will be sent.
If you're using phone sign-ins, only an OTP will be sent. You won't be able to send a magiclink for phone sign-ins.
```js
const { data, error } = await supabase.auth.signInWithOtp({
email: 'example@email.com',
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
SignInWithPasswordlessCredentials
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>reflection</code> | <code>reflection</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
<code>object</code>
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's phone number.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
captchaToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Verification token received when the user completes the captcha on the site.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
shouldCreateUser
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
If set to false, this method will not create a new user. Defaults to true.
</div>
</li>
</ul>
</li>
</ul>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
<code>object</code>
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email address.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
captchaToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Verification token received when the user completes the captcha on the site.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
emailRedirectTo
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The redirect url embedded in the email link
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
shouldCreateUser
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>boolean</code>
</span>
</h4>
<div class="method-list-item-description">
If set to false, this method will not create a new user. Defaults to true.
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
## Notes
- Requires either an email or phone number.
- This method is used for passwordless sign-ins where a OTP is sent to the user's email or phone number.
- If you're using an email, you can configure whether you want the user to receive a magiclink or a OTP.
- If you're using phone, you can configure whether you want the user to receive a OTP.
- The magic link's destination URL is determined by the [`SITE_URL`](https://supabase.com/docs/reference/auth/config#site_url). You can modify the `SITE_URL` or add additional redirect urls in [your project](https://app.supabase.com/project/_/auth/settings).
## Examples
### Sign in with email.
The user will be sent an email which contains either a magiclink or a OTP or both. By default, a given user can only request a OTP once every 60 seconds.
```js
const { data, error } = await supabase.auth.signInWithOtp({
email: 'example@email.com',
})
```
### Sign in with SMS OTP.
The user will be sent a SMS which contains a OTP. By default, a given user can only request a OTP once every 60 seconds.
```js
const { data, error } = await supabase.auth.signInWithPassword({
phone: '+13334445555',
})
```
@@ -1,299 +0,0 @@
---
id: auth-signinwithpassword
title: 'signInWithPassword()'
slug: /auth-signinwithpassword
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Log in an existing user with an email and password or phone and password.
```js
const { data, error } = await supabase.auth.signInWithPassword({
email: 'example@email.com',
password: 'example-password',
})
```
## Parameters
<ul className="method-list-group">
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
SignInWithPasswordCredentials
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>reflection</code> | <code>reflection</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
<code>object</code>
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
phone
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's phone number.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
password
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's password.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
captchaToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Verification token received when the user completes the captcha on the site.
</div>
</li>
</ul>
</li>
</ul>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
<code>object</code>
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
password
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's password.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
email
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
The user's email address.
</div>
</li>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
options
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>object</code>
</span>
</h4>
<div class="method-list-item-description">
No description provided.
</div>
<ul className="method-list-group">
<h5 class="method-list-title method-list-title-isChild expanded">Properties</h5>
<li className="method-list-item">
<h4 className="method-list-item-label">
<span className="method-list-item-label-name">
captchaToken
</span>
<span className="method-list-item-label-badge false">
optional
</span>
<span className="method-list-item-validation">
<code>string</code>
</span>
</h4>
<div class="method-list-item-description">
Verification token received when the user completes the captcha on the site.
</div>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
## Notes
- Requires either an email and password or a phone number and password.
## Examples
### Sign in with email and password
```js
const { data, error } = await supabase.auth.signInWithPassword({
email: 'example@email.com',
password: 'example-password',
})
```
### Sign in with phone and password
```js
const { data, error } = await supabase.auth.signInWithPassword({
phone: '+13334445555',
password: 'some-password',
})
// After receiving a SMS with a OTP.
const { data, error } = await supabase.auth.verifyOtp({
phone: '+13334445555',
token: '123456',
})
```
@@ -1,31 +0,0 @@
---
id: auth-signout
title: 'signOut()'
slug: /auth-signout
custom_edit_url: https://github.com/supabase/supabase/edit/master/spec/supabase_js_v2_legacy.yml
---
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
Inside a browser context, `signOut()` will remove the logged in user from the browser session
and log them out - removing all items from localstorage and then trigger a `"SIGNED_OUT"` event.
For server-side management, you can revoke all refresh tokens for a user by passing a user's JWT through to `auth.api.signOut(JWT: string)`.
There is no way to revoke a user's access token jwt until it expires. It is recommended to set a shorter expiry on the jwt for this reason.
```js
const { error } = await supabase.auth.signOut()
```
## Notes
- In order to use the `signOut()` method, the user needs to be signed in first.
## Examples
### Sign out
```js
const { error } = await supabase.auth.signOut()
```
Loaded 100 of 520 files, more files were not shown because too many files have changed in this diff. Show more