Expert guidance for Next.js 15+ App Router applications. Enforces security for Server Actions, proper Data Access Layer (DAL) separation, and React Server Component (RSC) best practices.
"use server")."use server";
import { z } from "zod";
import { verifySession } from "@/lib/dal";
const schema = z.object({ id: z.string() });
export async function deleteItem(formData: FormData) {
const session = await verifySession(); // Security Check
if (!session.isAdmin) throw new Error("Unauthorized");
const parsed = schema.safeParse(Object.fromEntries(formData));
if (!parsed.success) return { error: "Invalid data" };
// ... logic
}
data/ folder (DAL).app/page.tsx -> calls getDashboardData()data/dashboard.ts -> calls db.query() AND performs React cache() if needed.Promise.all in the parent component where possible.<Suspense fallback={<Skeleton />}>."use client" down the tree as far as possible (Leaf nodes).useState in them.