setting a cookie

I'm trying to store my cartId in a cookie
but idk why nextjs says

"Cookies can only be modified in a Server Action or Route Handler. Read more:"

when that function is a serverAction right?
//actions.ts
"use server"

export async function createCartIdCookie(formData: any) {
  const cookieStore = await cookies();

  const cartId = await createCart();
  cookieStore.set("cartId", cartId);

  return cartId;
}
Was this page helpful?