Any way to get cookies from client signIn methods when used as server action?

Any example
"use server";

import { signIn } from "@/src/lib/auth-client";
import { redirect } from "next/navigation";

export async function verifyEmailOtp(formData: FormData) {
const { error, data } = await signIn.emailOtp({
email: formData.get("email")?.toString() as string,
otp: formData.get("otp")?.toString() as string,
});
redirect("/auth/dashboard");
});
"use server";

import { signIn } from "@/src/lib/auth-client";
import { redirect } from "next/navigation";

export async function verifyEmailOtp(formData: FormData) {
const { error, data } = await signIn.emailOtp({
email: formData.get("email")?.toString() as string,
otp: formData.get("otp")?.toString() as string,
});
redirect("/auth/dashboard");
});
3 Replies
bekacru
bekacru2w ago
on the server you should use auth.api method
rhitune
rhitune2w ago
read docs pls
Karan
KaranOP2w ago
Got it. On the server, auth.api.emailOtp or auth.api.signin.emailOtp method is not available But it makes sense, we can just use fetch or something to make a call.

Did you find this page helpful?