Stabilize export const prefetch (#94571)

This API is going to ship stable but some options may individually be
marked unstable
This commit is contained in:
Josh Story
2026-06-08 18:30:55 -07:00
committed by GitHub
parent 409fa64d16
commit adb2913661
154 changed files with 208 additions and 207 deletions
+6 -6
View File
@@ -19,7 +19,7 @@ If you are generating a token to talk to a database that itself should be cached
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
async function getCachedData(token: string, userId: string) {
"use cache"
@@ -37,7 +37,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
async function getCachedData(userId: string) {
"use cache"
@@ -59,7 +59,7 @@ If you require this random value to be unique per Request and an async version o
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { generateKeySync } from 'node:crypto'
@@ -75,7 +75,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { generateKey } from 'node:crypto'
@@ -95,7 +95,7 @@ If you require this random value to be unique per Request and an async version o
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page({ params }) {
const { sessionId } = await params
@@ -107,7 +107,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { connection } from 'next/server'
@@ -23,7 +23,7 @@ If you are using the current time for performance tracking with elapsed time use
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page({ params }) {
const { id } = await params
@@ -39,7 +39,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page({ params }) {
const { id } = await params
@@ -61,7 +61,7 @@ If you want to read the time when some cache entry is created (such as when a Ne
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
async function InformationTable({ id }) {
const data = await fetch(urlFrom(id))
@@ -87,7 +87,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
async function InformationTable({ id }) {
'use cache'
@@ -124,7 +124,7 @@ If you go with this approach you will need to ensure the Client Component which
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
function RelativeTime({ when }) {
return computeTimeAgo(new Date(), when)
@@ -178,7 +178,7 @@ export function RelativeTime({ when }) {
```
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { RelativeTime } from './relative-time'
@@ -212,7 +212,7 @@ Next.js enforces that it can always produce at least a partially static initial
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page() {
const lastImpressionTime = (await cookies()).get(
@@ -230,7 +230,7 @@ export default async function Page() {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { Suspense } from 'react'
import { connection } from 'next/server'
+4 -4
View File
@@ -23,7 +23,7 @@ If your random value is cacheable, move the `Math.random()` call to a `"use cach
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page({ params }) {
const { category } = await params
@@ -37,7 +37,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
async function RandomizedProductsView({ category }) {
'use cache'
@@ -62,7 +62,7 @@ If you want the random value to be evaluated on each Request precede it with `aw
Before:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
export default async function Page({ params }) {
const { category } = await params
@@ -76,7 +76,7 @@ export default async function Page({ params }) {
After:
```jsx filename="app/page.js"
export const unstable_prefetch = 'allow-runtime'
export const prefetch = 'allow-runtime'
import { connection } from 'next/server'