We're laying the foundation for the future of Next.js with 12.2:
Update today by running npm i next@latest .
We're excited to announce Middleware is now stable in 12.2 and has an improved API based on feedback from users.
Middleware allows you to run code before a request is completed. Based on the incoming request, you can modify the response by rewriting, redirecting, adding headers, or setting cookies.
To update to the newest API changes for Middleware, please see the migration guide .
Try Middleware for free on Vercel or when self-hosting using next start .
On-Demand Incremental Static Regeneration (ISR) allows you to update the content on your site without needing to redeploy.
This is an excerpt. The full article is published by Next.js Blog.
Answers to common questions regarding this article's topic, architecture, and practical applications.
We're excited to announce Middleware is now stable in 12.2 and has an improved API based on feedback from users. Middleware allows you to run code before a request is completed. Based on the incoming request, you can modify the response by rewriting, redirecting, adding headers, or setting cookies. import { NextRequest, NextResponse } from 'next/server';
// If the incoming request has the "beta" cookie
// then we'll rewrite the request to /beta
General
We've heard your feedback on the current Image component and are excited to share an early preview of the new next/image. This new and improved image component requires less client-side JavaScript and simplifies how you style images: This improves performance because native loading="lazy" doesn't need to wait for React hydration and client-side JavaScript. For more information, check out the documentation.
General
On-Demand Incremental Static Regeneration (ISR) allows you to update the content on your site without needing to redeploy. This makes it easy to update your site immediately when data changes in your headless CMS or commerce platform. This was one of the most requested features from the community and we're excited it is now stable. export default async function handler(req, res) {
// Check for secret to confirm this is a valid request
if (req
General
Next.js now supports using the Edge Runtime for server rendering. As mentioned above, the Edge Runtime is a lighter-weight runtime than Node.js providing fast startups for low latency. When used with React 18, it enables streaming server-rendering for Pages. Next.js uses Node.js as the default runtime for server-side rendering pages. Starting with 12.2, if you are using React 18 you can opt into using the Edge Runtime. You can set the runtime glo
General
We're laying the foundation for the future of Next.js with 12.2: