i can't setup a supabase project
Answered
Asian black bear posted this in #help-forum
Asian black bearOP
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
export function createClient() {
const cookieStore = cookies()
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
getAll() {
return cookieStore.getAll()
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
cookieStore.set(name, value, options)
)
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
}
)
}import { createClient } from '@/utils/supabase/server';
export default async function Notes() {
const supabase = createClient();
const { data: notes } = await supabase.from("notes").select();
return <pre>{JSON.stringify(notes, null, 2)}</pre>
}× You're importing a component that needs next/headers. That only works in a Server Component which is not supported in the pages/ directory. Read more: https://nextjs.org/docs/getting-started/
9 Replies
Asian black bearOP
i got codes from
https://supabase.com/docs/guides/getting-started/quickstarts/nextjs
https://supabase.com/docs/guides/getting-started/quickstarts/nextjs
Asian black bearOP
why every thing against me
i hate this
oh i need
to
add
Asian black bearOP
'use server' on topAnswer
@Asian black bear Unless it's a server action, it's not needed I believe
can you show me your code?