Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

286
Views
Authentication not working with Supabase and Node.js

I am not sure even this is possible but I am trying to use Supabase with Node.js. I get the code from a React front-end, this link, which works okay.

Below is my code

client.js

const { createClient } = require('@supabase/supabase-js')

const supabaseUrl = "MY_URL"
const public_anon_key = "MY_ANON_KEY"
const supabase = createClient(supabaseUrl,public_anon_key)

exports.supabase = supabase

app.js

const { supabase }  = require('./client')

async function signOut() {
        /* sign the user out */
        await supabase.auth.signOut();
}

async function signInWithGithub() {
        /* authenticate with GitHub */
        await supabase.auth.signIn({
                provider: 'github'
        });
}

async function printUser() {
        const user = supabase.auth.user()
        console.log(user.email)
}

signInWithGithub()
printUser()
signOut()

I am new to Node.js and I suspect something wrong with Promises is missing. Is it possible to retrieve the user data from Supabase, if so, what is my code missing?

Thanks

Edit : title

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I don't know what Supabase does but the problem seems to be Promise related

Try to change your app.js as follow

const { supabase }  = require('./client')

function signOut() {
        /* sign the user out */
        supabase.auth.signOut();
}

function signInWithGithub() {
        /* authenticate with GitHub */
        return  supabase.auth.signIn({
                provider: 'github'
        });
}
function printUser() {
        const user = supabase.auth.user()
        console.log(user.email)
}

signInWithGithub().then(() => {
   printUser()
   return signOut()

})

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!