© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
34 replies
chaos

signinwithotp

has this changed for creating new users? before new user was created if they did not have an account. now it seems not functioning?

i try many times. here my code:

export const signIn = async (email) => {
console.log("signing in attempt")
if (!email) {
alert("Please enter your email.");
return;
}
try {

await createUser(email)

let { data, error } = await supabase.auth.signInWithOtp({email})
if (error) {
console.error(error);
}
} catch (error) {
console.error(error);
}
};

export const signOut = async () => {
try {
const { error } = await supabase.auth.signOut();
if (error) throw error;
} catch (error) {
alert(error.error_description || error.message);
}
};


export const createUser = async (email) => {
let { data: existingUser, error } = await supabase
.from('users')
.select('email')
.eq('email', email)
.single()

if (error) {
console.error(error);
return;
}

if (!existingUser) {
const { data, error } = await supabase
.from('users')
.insert({ email });

if (error) {
console.error(error);
} else {
if (typeof window !== 'undefined') {
localStorage.setItem('userInDB', true)
}
}
}
}
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Is signInWithOtp() broken?
SupabaseSSupabase / help-and-questions
2mo ago
Error 535 from signInWithOtp
SupabaseSSupabase / help-and-questions
4y ago
Setting signInWithOtp Site URL?
SupabaseSSupabase / help-and-questions
4y ago
signInWithOtp always redirects to localhost3000
SupabaseSSupabase / help-and-questions
4y ago