mirror of
https://github.com/supabase/supabase.git
synced 2026-05-24 04:00:47 +08:00
186 lines
4.3 KiB
Plaintext
186 lines
4.3 KiB
Plaintext
---
|
|
id: auth-signup
|
|
title: 'signUp()'
|
|
slug: auth-signup
|
|
custom_edit_url: https://github.com/supabase/supabase/edit/master/web/spec/supabase.yml
|
|
---
|
|
|
|
import Tabs from '@theme/Tabs'
|
|
import TabsPanel from '@theme/TabsPanel'
|
|
|
|
Creates a new user.
|
|
|
|
<Tabs
|
|
defaultActiveId="js"
|
|
groupId="reference/supabase-js"
|
|
values={[{ label: 'JavaScript', value: 'js' }]}>
|
|
|
|
<TabsPanel id="js" label="js">
|
|
|
|
```js
|
|
const { user, session, error } = await supabase.auth.signUp({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
## Parameters
|
|
|
|
<ul className="method-list-group">
|
|
|
|
<li className="method-list-item">
|
|
<h4 className="method-list-item-label">
|
|
<span className="method-list-item-label-name">
|
|
__namedParameters
|
|
</span>
|
|
<span className="method-list-item-label-badge required">
|
|
required
|
|
</span>
|
|
<span className="method-list-item-validation">
|
|
<code>UserCredentials</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">
|
|
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">
|
|
|
|
No description provided.
|
|
|
|
</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">
|
|
|
|
No description provided.
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
## 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)
|
|
- If signUp() is called for an existing confirmed user:
|
|
- If "Enable email confirmations" is enabled on the "Authentication" -> "Settings" page, an obfuscated / fake user object will be returned.
|
|
- If "Enable email confirmations" is disabled, an error with a message "User already registered" will be returned.
|
|
- To check if a user already exists, refer to getUser().
|
|
|
|
## Examples
|
|
|
|
### Sign up.
|
|
|
|
<Tabs
|
|
defaultActiveId="js"
|
|
groupId="reference/supabase-js"
|
|
values={[{ label: 'JavaScript', value: 'js' }]}>
|
|
|
|
<TabsPanel id="js" label="js">
|
|
|
|
```js
|
|
const { user, session, error } = await supabase.auth.signUp({
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
})
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Sign up with additional user meta data.
|
|
|
|
<Tabs
|
|
defaultActiveId="js"
|
|
groupId="reference/supabase-js"
|
|
values={[{ label: 'JavaScript', value: 'js' }]}>
|
|
|
|
<TabsPanel id="js" label="js">
|
|
|
|
```js
|
|
const { user, session, error } = await supabase.auth.signUp(
|
|
{
|
|
email: 'example@email.com',
|
|
password: 'example-password',
|
|
},
|
|
{
|
|
data: {
|
|
first_name: 'John',
|
|
age: 27,
|
|
},
|
|
}
|
|
)
|
|
```
|
|
|
|
</TabsPanel>
|
|
|
|
</Tabs>
|
|
|
|
### Sign up with third-party providers.
|
|
|
|
You can sign up with OAuth providers using the [`signIn()`](/docs/reference/javascript/auth-signin#sign-in-using-third-party-providers) method.
|