Skip to content
This repository was archived by the owner on Oct 23, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/unlucky-jobs-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@supabase/auth-ui-react': patch
'@supabase/auth-ui-shared': patch
'@supabase/auth-ui-solid': patch
'@supabase/auth-ui-svelte': patch
---

Add additional data to component to store in user_metadata
4 changes: 4 additions & 0 deletions packages/react/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ function Auth({
theme = 'default',
localization = { variables: {} },
otpType = 'email',
additionalData,
children,
}: AuthProps): JSX.Element | null {
/**
* Localization support
Expand Down Expand Up @@ -159,6 +161,8 @@ function Auth({
magicLink={magicLink}
showLinks={showLinks}
i18n={i18n}
additionalData={additionalData}
children={children}
/>
</Container>
)
Expand Down
16 changes: 12 additions & 4 deletions packages/react/src/components/Auth/interfaces/EmailAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ export interface EmailAuthProps {
supabaseClient: SupabaseClient
showLinks?: boolean
redirectTo?: RedirectTo
additionalData?: { [key: string]: any }
magicLink?: boolean
i18n?: I18nVariables
appearance?: Appearance
children?: React.ReactNode
}

function EmailAuth({
Expand All @@ -43,9 +45,11 @@ function EmailAuth({
supabaseClient,
showLinks = false,
redirectTo,
additionalData,
magicLink,
i18n,
appearance,
children,
}: EmailAuthProps) {
const isMounted = useRef<boolean>(true)
const [email, setEmail] = useState(defaultEmail)
Expand Down Expand Up @@ -78,15 +82,19 @@ function EmailAuth({
if (signInError) setError(signInError.message)
break
case 'sign_up':
let options: { emailRedirectTo: RedirectTo; data?: object } = {
emailRedirectTo: redirectTo,
}
if (additionalData) {
options.data = additionalData
}
const {
data: { user: signUpUser, session: signUpSession },
error: signUpError,
} = await supabaseClient.auth.signUp({
email,
password,
options: {
emailRedirectTo: redirectTo,
},
options,
})
if (signUpError) setError(signUpError.message)
// Check if session is null -> email confirmation setting is turned on
Expand Down Expand Up @@ -127,7 +135,6 @@ function EmailAuth({
id="email"
type="email"
name="email"
autoFocus
placeholder={labels?.email_input_placeholder}
defaultValue={email}
onChange={(e: React.ChangeEvent<HTMLInputElement>) =>
Expand Down Expand Up @@ -156,6 +163,7 @@ function EmailAuth({
appearance={appearance}
/>
</div>
{children}
</Container>

<Button
Expand Down
33 changes: 28 additions & 5 deletions packages/react/src/components/Auth/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const SignUp = (
}

export const SignIn = (
props: Omit<AuthProps, 'view' | 'onlyThirdPartyProviders'>
props: Omit<AuthProps, 'view' | 'onlyThirdPartyProviders' | 'additionalData'>
) => {
return (
<Auth
Expand All @@ -60,7 +60,11 @@ export const SignIn = (
export const MagicLink = (
props: Omit<
AuthProps,
'view' | 'onlyThirdPartyProviders' | 'magicLink' | 'showLinks'
| 'view'
| 'onlyThirdPartyProviders'
| 'magicLink'
| 'showLinks'
| 'additionalData'
>
) => {
return <Auth {...props} view="magic_link" showLinks={false} />
Expand All @@ -69,7 +73,11 @@ export const MagicLink = (
export const SocialAuth = (
props: Omit<
AuthProps,
'view' | 'onlyThirdPartyProviders' | 'magicLink' | 'showLinks'
| 'view'
| 'onlyThirdPartyProviders'
| 'magicLink'
| 'showLinks'
| 'additionalData'
>
) => {
return (
Expand All @@ -82,11 +90,26 @@ export const SocialAuth = (
)
}

export const ForgottenPassword = (props: Omit<AuthProps, 'view'>) => {
export const ForgottenPassword = (
props: Pick<
AuthProps,
| 'supabaseClient'
| 'appearance'
| 'localization'
| 'theme'
| 'showLinks'
| 'redirectTo'
>
) => {
return <Auth showLinks={false} {...props} view="forgotten_password" />
}

export const UpdatePassword = (props: Omit<AuthProps, 'view'>) => {
export const UpdatePassword = (
props: Pick<
AuthProps,
'supabaseClient' | 'appearance' | 'localization' | 'theme'
>
) => {
return <Auth {...props} view="update_password" />
}

Expand Down
1 change: 1 addition & 0 deletions packages/shared/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface BaseAuth {
magicLink?: boolean
showLinks?: boolean
otpType?: OtpType
additionalData?: { [key: string]: any }

/**
* This will toggle on the dark variation of the theme
Expand Down
5 changes: 4 additions & 1 deletion packages/solid/src/components/Auth/Auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ function Auth(props: AuthProps): JSX.Element | null {
magicLink={mergedProps().magicLink}
showLinks={mergedProps().showLinks}
i18n={i18n()}
/>
additionalData={mergedProps().additionalData}
>
{props.children}
</EmailAuth>
</Container>
</Match>

Expand Down
15 changes: 11 additions & 4 deletions packages/solid/src/components/Auth/interfaces/EmailAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-case-declarations */
import { SupabaseClient } from '@supabase/supabase-js'
import { createEffect, createSignal, Setter } from 'solid-js'
import { createEffect, createSignal, JSXElement, Setter } from 'solid-js'
import {
I18nVariables,
RedirectTo,
Expand All @@ -22,9 +22,11 @@ export interface EmailAuthProps {
supabaseClient: SupabaseClient
showLinks?: boolean
redirectTo?: RedirectTo
additionalData?: { [key: string]: any }
magicLink?: boolean
i18n: I18nVariables
appearance?: Appearance
children?: JSXElement
}

const VIEWS: ViewsMap = {
Expand Down Expand Up @@ -66,15 +68,19 @@ function EmailAuth(props: EmailAuthProps) {
if (signInError) setError(signInError.message)
break
case 'sign_up':
let options: { emailRedirectTo: RedirectTo; data?: object } = {
emailRedirectTo: props.redirectTo,
}
if (props.additionalData) {
options.data = props.additionalData
}
const {
data: { user: signUpUser, session: signUpSession },
error: signUpError,
} = await props.supabaseClient.auth.signUp({
email: email(),
password: password(),
options: {
emailRedirectTo: props.redirectTo,
},
options,
})
if (signUpError) setError(signUpError.message)
// Check if session is null -> email confirmation setting is turned on
Expand Down Expand Up @@ -148,6 +154,7 @@ function EmailAuth(props: EmailAuthProps) {
appearance={props.appearance}
/>
</div>
{props.children}
</Container>

<Button
Expand Down
19 changes: 15 additions & 4 deletions packages/solid/src/components/Auth/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ export const SignUp = (
{...props}
onlyThirdPartyProviders={false}
view="sign_up"
/>
>
{props.children}
</Auth>
)
}

export const SignIn = (
props: Omit<AuthProps, 'view' | 'onlyThirdPartyProviders'>
props: Omit<AuthProps, 'view' | 'onlyThirdPartyProviders' | 'additionalData'>
) => {
return (
<Auth
Expand All @@ -60,7 +62,11 @@ export const SignIn = (
export const MagicLink = (
props: Omit<
AuthProps,
'view' | 'onlyThirdPartyProviders' | 'magicLink' | 'showLinks'
| 'view'
| 'onlyThirdPartyProviders'
| 'magicLink'
| 'showLinks'
| 'additionalData'
>
) => {
return <Auth {...props} view="magic_link" showLinks={false} />
Expand All @@ -69,7 +75,12 @@ export const MagicLink = (
export const SocialAuth = (
props: Omit<
AuthProps,
'view' | 'onlyThirdPartyProviders' | 'magicLink' | 'showLinks' | 'children'
| 'view'
| 'onlyThirdPartyProviders'
| 'magicLink'
| 'showLinks'
| 'children'
| 'additionalData'
>
) => {
return (
Expand Down
7 changes: 5 additions & 2 deletions packages/svelte/src/lib/Auth/Auth.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
export let theme: 'default' | string = 'default';
export let localization: { variables?: I18nVariables } = {};
export let otpType: OtpType = 'email';
export let additionalData: { [key: string]: any } | undefined;

onMount(() => {
const { data: authListener } = supabaseClient.auth.onAuthStateChange((event) => {
Expand Down Expand Up @@ -93,6 +94,7 @@
{magicLink}
{showLinks}
{i18n}
{additionalData}
/>
{/if}
{/if}
Expand All @@ -105,8 +107,9 @@
{redirectTo}
{magicLink}
{showLinks}
{i18n}
/>
{additionalData}
{i18n}><slot /></EmailAuth
>
{/if}
{/if}
{#if view === VIEWS.FORGOTTEN_PASSWORD}
Expand Down
25 changes: 19 additions & 6 deletions packages/svelte/src/lib/Auth/interfaces/EmailAuth.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@
import Input from '$lib/UI/Input.svelte';
import Label from '$lib/UI/Label.svelte';
import Message from '$lib/UI/Message.svelte';
import { VIEWS, type I18nVariables, type ViewType } from '@supabase/auth-ui-shared';
import {
VIEWS,
type I18nVariables,
type ViewType,
type RedirectTo
} from '@supabase/auth-ui-shared';
import type { Appearance } from '$lib/types';

export let authView: ViewType = 'sign_in';
export let email = '';
export let password = '';
export let supabaseClient: SupabaseClient;
export let redirectTo: string | undefined = undefined;
export let redirectTo: RedirectTo = undefined;
export let additionalData: { [key: string]: any } | undefined = undefined;
export let showLinks = false;
export let magicLink = true;
export let i18n: I18nVariables;
Expand All @@ -40,15 +46,19 @@
loading = false;
break;
case VIEWS.SIGN_UP:
let options: { emailRedirectTo: RedirectTo; data?: object } = {
emailRedirectTo: redirectTo
};
if (additionalData) {
options.data = additionalData;
}
const {
data: { user: signUpUser, session: signUpSession },
error: signUpError
} = await supabaseClient.auth.signUp({
email,
password,
options: {
emailRedirectTo: redirectTo
}
options
});

if (signUpError) error = signUpError.message;
Expand Down Expand Up @@ -88,8 +98,11 @@
{appearance}
/>
</div>
<slot />
</Container>
<Button type="submit" color="primary" {loading} {appearance}>{i18n?.[lngKey]?.button_label}</Button>
<Button type="submit" color="primary" {loading} {appearance}
>{i18n?.[lngKey]?.button_label}</Button
>

{#if showLinks}
<Container direction="vertical" gap="small" {appearance}>
Expand Down
6 changes: 5 additions & 1 deletion packages/svelte/src/lib/Auth/ui/SignUp.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
export let appearance: Appearance = {};
export let theme: 'default' | string = 'default';
export let localization: { variables?: I18nVariables } = {};
export let additionalData: { [key: string]: any } | undefined = undefined;
</script>

<Auth
Expand All @@ -36,4 +37,7 @@
{appearance}
{theme}
{localization}
/>
{additionalData}
>
<slot />
</Auth>