--- 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 ## 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` and `phone_confirm` options to this function, both will default to false. ## Examples ### Create a new user. ```js const { data, error } = await supabase.auth.admin.createUser({ email: 'user@email.com', password: 'password', user_metadata: { name: 'Yoda' }, }) ``` ### Auto-confirm email. ```js const { data, error } = await supabase.auth.admin.createUser({ email: 'user@email.com', email_confirm: true, }) ``` ### Auto-confirm phone. ```js const { data, error } = await supabase.auth.admin.createUser({ phone: '1234567890', phone_confirm: true, }) ```