Next.js 15 represents a major evolution in React frameworks, with stable Server Actions, groundbreaking Partial Prerendering, and a completely redesigned caching system.
Server Actions: Stable and Production-Ready
Server Actions are now stable and the recommended way to handle mutations in Next.js:
// app/actions.ts
"use server"
export async function createPost(formData: FormData) {
const title = formData.get("title") as string;
const content = formData.get("content") as string;
await db.posts.create({ title, content });
revalidatePath("/posts");
}
// app/new-post/page.tsx
import { createPost } from "./actions";
export default function NewPost() {
return (
<form action={createPost}>
<input name="title" required />
<textarea name="content" required />
<button type="submit">Create Post</button>
</form>
);
}
Partial Prerendering (PPR)
PPR combines static and dynamic content on the same page:
- Static shell loads instantly from CDN
- Dynamic content streams in as it's ready
- Best of both SSG and SSR worlds
// next.config.js
module.exports = {
experimental: {
ppr: true,
},
};
// app/page.tsx
import { Suspense } from "react";
export default function Page() {
return (
<div>
<StaticHeader /> {/* Prerendered */}
<Suspense fallback={<Loading />}>
<DynamicContent /> {/* Streamed */}
</Suspense>
</div>
);
}
New Caching Defaults
Next.js 15 changes caching to be opt-in rather than opt-out:
- fetch() requests are no longer cached by default
- Route handlers are dynamic by default
- Use
cache: "force-cache"for static data
Migration Guide
- Update package:
npm install next@15 - Review caching behavior for data fetching
- Convert API routes to Server Actions where possible
- Enable PPR for hybrid pages
Comments (0)
Leave a Comment
No comments yet. Be the first to share your thoughts!