createUser()
Creates a new user.
This function should only be called on a server. Never expose your service_role
key in the browser.
const { data: user, error } = await supabase.auth.api.createUser({
email: 'user@email.com',
password: 'password',
user_metadata: { name: 'Yoda' }
})
Parameters
attributesrequired
AdminUserAttributes
The data you want to create the user with.
Notes
- Requires a
service_role
key. - This function should be called on a server. Never expose your
service_role
key in the browser. - If you do not provide the
email_confirm
andphone_confirm
options to this function, both will default to false.
Examples
Create a new user.
const { data: user, error } = await supabase.auth.api.createUser({
email: 'user@email.com',
password: 'password',
user_metadata: { name: 'Yoda' }
})
Auto-confirm email.
const { data: user, error } = await supabase.auth.api.createUser({
email: 'user@email.com',
email_confirm: true
})
Auto-confirm phone.
const { data: user, error } = await supabase.auth.api.createUser({
phone: '1234567890',
phone_confirm: true
})