Next.js Discord

Discord Forum

Error: Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null pro

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
'use server'

import { redirect } from "next/navigation";
import { createClientForServer } from "./server"


export async function signInWithGoogle() {
    console.log("hi")
    const supabase = await createClientForServer();

    const auth_callback_url = `${process.env.SITE_URL}/auth/callback`;

    const { data, error } = await supabase.auth.signInWithOAuth({
        provider: "google",
        options: {
            redirectTo: auth_callback_url
        }
    });

    if (error) {
        console.error("Auth Error:", error);
        return;
    }

    console.log("Redirecting to:", data.url);
    redirect(data.url);
}

1 Reply

Asian black bearOP
i used with my button like :

<Button
            onPress={signInWithGoogle}
            startContent={<Icon icon="flat-color-icons:google" width={24} />}
            variant="bordered"
          >
            Sign Up with Google
          </Button>