Skip to content

Commit 2ba4a85

Browse files
authored
global-error, revalidatePath and PWA headings (#82408)
Complement to: #82379 Also adding corrections to other sections
1 parent d016157 commit 2ba4a85

File tree

4 files changed

+21
-7
lines changed

4 files changed

+21
-7
lines changed

docs/01-app/01-getting-started/14-metadata-and-og-images.mdx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ The Metadata APIs can be used to define your application metadata for improved S
2323

2424
With all the options above, Next.js will automatically generate the relevant `<head>` tags for your page, which can be inspected in the browser's developer tools.
2525

26+
The `metadata` object and `generateMetadata` function exports are only supported in Server Components.
27+
2628
## Default fields
2729

2830
There are two default `meta` tags that are always added even if a route doesn't define metadata:

docs/01-app/02-guides/progressive-web-apps.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ Let’s go over each of these options:
648648
649649
Learn more about defining [Content Security Policies](/docs/app/guides/content-security-policy) with Next.js.
650650
651-
## Next Steps
651+
## Extending your PWA
652652
653653
1. **Exploring PWA Capabilities**: PWAs can leverage various web APIs to provide advanced functionality. Consider exploring features like background sync, periodic background sync, or the File System Access API to enhance your application. For inspiration and up-to-date information on PWA capabilities, you can refer to resources like [What PWA Can Do Today](https://whatpwacando.today/).
654654
2. **Static Exports:** If your application requires not running a server, and instead using a static export of files, you can update the Next.js configuration to enable this change. Learn more in the [Next.js Static Export documentation](/docs/app/guides/static-exports). However, you will need to move from Server Actions to calling an external API, as well as moving your defined headers to your proxy.

docs/01-app/03-api-reference/03-file-conventions/error.mdx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ export default function Error({ error, reset }) {
153153

154154
### Global Error
155155

156-
While less common, you can handle errors in the root layout or template using `global-error.js`, located in the root app directory, even when leveraging [internationalization](/docs/app/guides/internationalization). Global error UI must define its own `<html>` and `<body>` tags. This file replaces the root layout or template when active.
156+
While less common, you can handle errors in the root layout or template using `global-error.js`, located in the root app directory, even when leveraging [internationalization](/docs/app/guides/internationalization). Global error UI must define its own `<html>` and `<body>` tags, global styles, fonts, or other dependencies that your error page requires. This file replaces the root layout or template when active.
157+
158+
> **Good to know**: Error boundaries must be [Client Components](/docs/app/getting-started/server-and-client-components#using-client-components), which means that [`metadata` and `generateMetadata`](/docs/app/getting-started/metadata-and-og-images) exports are not supported in `global-error.js`. As an alternative, you can use the React [`<title>`](https://react.dev/reference/react-dom/components/title) component.
157159
158160
```tsx filename="app/global-error.tsx" switcher
159161
'use client' // Error boundaries must be Client Components

docs/01-app/03-api-reference/04-functions/revalidatePath.mdx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ The path parameter can point to pages, layouts, or route handlers:
3535

3636
- **Pages**: Revalidates the specific page
3737
- **Layouts**: Revalidates the layout and all pages beneath it
38-
- **GET Route Handlers**: Only if they're statically generated
38+
- **Route Handlers**: Revalidates Data Cache entries accessed within route handlers. For example `revalidatePath("/api/data")` revalidates this GET handler:
39+
40+
```ts filename="app/api/data/route.ts"
41+
export async function GET() {
42+
const data = await fetch('https://api.vercel.app/blog', {
43+
cache: 'force-cache',
44+
})
45+
46+
return Response.json(await data.json())
47+
}
48+
```
3949

4050
## Relationship with `revalidateTag`
4151

@@ -84,7 +94,7 @@ This pattern ensures that both the specific page and any other pages using the s
8494

8595
## Examples
8696

87-
### Revalidating A Specific URL
97+
### Revalidating a specific URL
8898

8999
```ts
90100
import { revalidatePath } from 'next/cache'
@@ -93,7 +103,7 @@ revalidatePath('/blog/post-1')
93103

94104
This will revalidate one specific URL on the next page visit.
95105

96-
### Revalidating A Page Path
106+
### Revalidating a Page path
97107

98108
```ts
99109
import { revalidatePath } from 'next/cache'
@@ -104,7 +114,7 @@ revalidatePath('/(main)/blog/[slug]', 'page')
104114

105115
This will revalidate any URL that matches the provided `page` file on the next page visit. This will _not_ invalidate pages beneath the specific page. For example, `/blog/[slug]` won't invalidate `/blog/[slug]/[author]`.
106116

107-
### Revalidating A Layout Path
117+
### Revalidating a Layout path
108118

109119
```ts
110120
import { revalidatePath } from 'next/cache'
@@ -115,7 +125,7 @@ revalidatePath('/(main)/post/[slug]', 'layout')
115125

116126
This will revalidate any URL that matches the provided `layout` file on the next page visit. This will cause pages beneath with the same layout to revalidate on the next visit. For example, in the above case, `/blog/[slug]/[another]` would also revalidate on the next visit.
117127

118-
### Revalidating All Data
128+
### Revalidating all data
119129

120130
```ts
121131
import { revalidatePath } from 'next/cache'

0 commit comments

Comments
 (0)