Next.js Discord

Discord Forum

supabase run time error

Unanswered
Channel catfish posted this in #help-forum
Open in Discord
Channel catfishOP
I was trying to create a chat on this site with supabase and next.js. I made all the code the same as the site's code, but I got this error. What should I do? Please tell me.
https://note.com/libproc/n/n168e87864291
import { createServerComponentClient } from "@supabase/auth-helpers-nextjs"
import { cookies } from "next/headers"
import Navigation from "./navigation"

const SupabaseListener = async () => {
    const supabase = createServerComponentClient({ cookies })

    const {
        data: { session },
    } = await supabase.auth.getSession()

    return <Navigation session={session} />
}

export default SupabaseListener;

2 Replies

did you declare the required environment variables? it looks like this method is trying to read an URL value and it is not defined
fwiw supabase doesn't recommend using the auth-helpers package anymore, it has been replaced with @supabase/ssr: https://supabase.com/docs/guides/auth/server-side/nextjs