Files
supabase/apps/temp-docs/docs/reference/javascript/auth-api-createuser.mdx
2022-04-26 14:17:19 +02:00

97 lines
1.6 KiB
Plaintext

---
id: auth-api-createuser
title: "createUser()"
slug: auth-api-createuser
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.
This function should only be called on a server. Never expose your `service_role` key in the browser.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.createUser({
name: 'Yoda'
})
```
</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">
attributes
</span>
<span className="method-list-item-label-badge required">
required
</span>
<span className="method-list-item-validation">
<code>UserAttributes</code>
</span>
</h4>
<div class="method-list-item-description">
The data you want to create the user with.
</div>
</li>
</ul>
## Notes
- Requires a `service_role` key.
- This function should be called on a server. Never expose your `service_role` key in the browser.
## Examples
### Create a new user.
<Tabs
defaultActiveId="js"
groupId="reference/supabase-js"
values={[{ label: 'JavaScript', value: 'js' }]}>
<TabsPanel id="js" label="js">
```js
const { data: user, error } = await supabase.auth.api.createUser({
name: 'Yoda'
})
```
</TabsPanel>
</Tabs>