You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next.js 15 App Router patterns. Trigger: When working in Next.js App Router (app/), Server Components vs Client Components, Server Actions, Route Handlers, caching/revalidation, and streaming/Suspense.
// No directive needed - async by defaultexportdefaultasyncfunctionPage(){constdata=awaitdb.query();return<Componentdata={data}/>;}
Server Actions
// app/actions.ts"use server";import{revalidatePath}from"next/cache";import{redirect}from"next/navigation";exportasyncfunctioncreateUser(formData: FormData){constname=formData.get("name")asstring;awaitdb.users.create({data: { name }});revalidatePath("/users");redirect("/users");}// Usage<formaction={createUser}><inputname="name"required/><buttontype="submit">Create</button></form>
Data Fetching
// ParallelasyncfunctionPage(){const[users,posts]=awaitPromise.all([getUsers(),getPosts(),]);return<Dashboardusers={users}posts={posts}/>;}// Streaming with Suspense<Suspensefallback={<Loading/>}><SlowComponent/></Suspense>