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
Removes the unstable prefix from `unstable_io`. Since this was only
shipped in canaries with the unstable prefix we are going to just remove
it without retaining the unstable prefix simultaneously.
Copy file name to clipboardExpand all lines: docs/01-app/03-api-reference/04-functions/io.mdx
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,22 @@
1
1
---
2
-
title: unstable_io
3
-
description: API Reference for the unstable_io function.
2
+
title: io
3
+
description: API Reference for the io function.
4
4
version: draft
5
5
---
6
6
7
-
`unstable_io()` informs Next.js that an IO operation will follow this call. When [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents) is not enabled or when rendering in Pages Router, signifying IO in this way is not meaningful and the call will always resolve immediately. When Cache Components is enabled, you may be required to add `await unstable_io()` preceding synchronous IO that is encountered while prerendering pages (`new Date()` for example). Additionally, if you want to avoid having genuine uncached IO invoked while prerendering, you shield it by preceeding it with `await unstable_io()`.
7
+
`io()` informs Next.js that an IO operation will follow this call. When [Cache Components](/docs/app/api-reference/config/next-config-js/cacheComponents) is not enabled or when rendering in Pages Router, signifying IO in this way is not meaningful and the call will always resolve immediately. When Cache Components is enabled, you may be required to add `await io()` preceding synchronous IO that is encountered while prerendering pages (`new Date()` for example). Additionally, if you want to avoid having genuine uncached IO invoked while prerendering, you shield it by preceeding it with `await io()`.
8
8
9
9
```ts filename="app/page.tsx" switcher
10
-
import { unstable_io } from'next/cache'
10
+
import { io } from'next/cache'
11
11
import { db } from'@/lib/db'
12
12
13
13
exportdefaultasyncfunction Page() {
14
14
// Synchronous IO: new Date() would fail during prerender without this
15
-
awaitunstable_io()
15
+
awaitio()
16
16
const now =newDate().toISOString()
17
17
18
18
// Async IO: the query would run and be discarded during prerender;
19
-
//unstable_io() above lets Next.js skip it entirely
19
+
//io() above lets Next.js skip it entirely
20
20
const orders =awaitdb.query('SELECT * FROM orders LIMIT 10')
21
21
22
22
return (
@@ -33,16 +33,16 @@ export default async function Page() {
33
33
```
34
34
35
35
```js filename="app/page.js" switcher
36
-
import { unstable_io } from'next/cache'
36
+
import { io } from'next/cache'
37
37
import { db } from'@/lib/db'
38
38
39
39
exportdefaultasyncfunctionPage() {
40
40
// Synchronous IO: new Date() would fail during prerender without this
41
-
awaitunstable_io()
41
+
awaitio()
42
42
constnow=newDate().toISOString()
43
43
44
44
// Async IO: the query would run and be discarded during prerender;
45
-
//unstable_io() above lets Next.js skip it entirely
45
+
//io() above lets Next.js skip it entirely
46
46
constorders=awaitdb.query('SELECT * FROM orders LIMIT 10')
47
47
48
48
return (
@@ -62,16 +62,16 @@ export default async function Page() {
62
62
63
63
[`connection()`](/docs/app/api-reference/functions/connection) requires an active HTTP request context and signals that the component needs request-specific data. It is imported from `next/server`.
64
64
65
-
`unstable_io()` does not require a request context. It can be used inside `"use cache"` scopes, client components, and anywhere you perform IO that should not be included in a static prerender. It is imported from `next/cache`.
65
+
`io()` does not require a request context. It can be used inside `"use cache"` scopes, client components, and anywhere you perform IO that should not be included in a static prerender. It is imported from `next/cache`.
66
66
67
-
Use `connection()` when you need the request itself (cookies, headers, etc.). Use `unstable_io()` when you perform IO that is independent of the request but should still prevent static prerendering.
67
+
Use `connection()` when you need the request itself (cookies, headers, etc.). Use `io()` when you perform IO that is independent of the request but should still prevent static prerendering.
68
68
69
69
## Reference
70
70
71
71
### Type
72
72
73
73
```ts
74
-
functionunstable_io():Promise<void>
74
+
functionio():Promise<void>
75
75
```
76
76
77
77
### Parameters
@@ -84,12 +84,12 @@ function unstable_io(): Promise<void>
0 commit comments