© 2026 Hedgehog Software, LLC
getServerSession
"use server"; import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import prisma from "@/db"; import { EventPrivacy } from "@prisma/client"; import { getServerSession } from "next-auth"; import { redirect } from "next/navigation"; export async function createEvent(formData: FormData) { const session = await getServerSession(authOptions); if (!session) return; const event = await prisma.event.create({ data: { image: formData.get("imageUrl") as string, name: formData.get("name") as string, description: formData.get("description") as string, startDate: new Date(formData.get("startDate") as string), endDate: new Date(formData.get("endDate") as string), privacy: formData.get("privacy") as EventPrivacy, createdById: session.user.id } }); redirect(`/event/${event.id}`); }
action
Method expects to have requestAsyncStorage, none available