Unverified Commit ad3296b9 authored by Mitul Shah's avatar Mitul Shah Committed by GitHub

Update default error pages (#90469)

Redesign the https://github.com/vercel/next.js/pull/87988 error pages to
be more aligned with Next.js aesthetic, along with copy to be sharper.

| Client | Server |
|--------|--------|
| <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 26
07@2x"
src="https://github.com/user-attachments/assets/f42bee3e-2ce8-44dc-9e26-79b81cf965d8"
/> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 23
38@2x"
src="https://github.com/user-attachments/assets/19a596c6-6da7-4a42-9b53-16e3c2e6f867"
/> |
| <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 25
22@2x"
src="https://github.com/user-attachments/assets/a3075d79-c76a-4fbf-af6e-d4a44f1434eb"
/> | <img width="4992" height="2830" alt="CleanShot 2026-03-03 at 17 24
17@2x"
src="https://github.com/user-attachments/assets/5811cc98-f8e4-4451-bf9c-501548292245"
/> |

---------
Co-authored-by: 's avatarJimmy Lai <laijimmy0@gmail.com>
Co-authored-by: 's avatarTim Neutkens <tim@timneutkens.nl>
parent 11c906a7
import React from 'react'
import { errorStyles, errorThemeCss, ErrorIcon } from './error-styles'
import { errorStyles, errorThemeCss, WarningIcon } from './error-styles'
// This is the static 500.html page for App Router apps.
// Always a server error, rendered at build time.
......@@ -7,23 +7,20 @@ function AppError() {
return (
<html id="__next_error__">
<head>
<title>500: This page failed to load</title>
<title>500: This page couldn&#x2019;t load</title>
<style dangerouslySetInnerHTML={{ __html: errorThemeCss }} />
</head>
<body>
<div style={errorStyles.container}>
<div style={errorStyles.card}>
<ErrorIcon />
<h1 style={errorStyles.title}>This page failed to load</h1>
<WarningIcon />
<h1 style={errorStyles.title}>This page couldn&#x2019;t load</h1>
<p style={errorStyles.message}>
Something went wrong while loading this page.
A server error occurred. Reload to try again.
</p>
<p style={errorStyles.messageHint}>
If this keeps happening, it may be a server issue.
</p>
<form>
<form style={errorStyles.form}>
<button type="submit" style={errorStyles.button}>
Reload page
Reload
</button>
</form>
</div>
......
......@@ -10,44 +10,46 @@ export const errorStyles = {
justifyContent: 'center',
},
card: {
maxWidth: '420px',
marginTop: '-32px',
maxWidth: '325px',
padding: '32px 28px',
textAlign: 'left' as const,
},
icon: {
marginBottom: '16px',
marginBottom: '24px',
},
title: {
fontSize: '17px',
fontWeight: 600,
letterSpacing: '-0.01em',
margin: '0 0 8px 0',
fontSize: '24px',
fontWeight: 500,
letterSpacing: '-0.02em',
lineHeight: '32px',
margin: '0 0 12px 0',
color: 'var(--next-error-title)',
},
message: {
fontSize: '14px',
fontWeight: 400,
lineHeight: 1.6,
margin: '0 0 6px 0',
lineHeight: '21px',
margin: '0 0 20px 0',
color: 'var(--next-error-message)',
},
messageHint: {
fontSize: '13px',
fontWeight: 400,
lineHeight: 1.5,
margin: '0 0 20px 0',
color: 'var(--next-error-hint)',
form: {
margin: 0,
},
buttonGroup: {
display: 'flex',
gap: '12px',
gap: '8px',
alignItems: 'center',
},
button: {
padding: '10px 20px',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
height: '32px',
padding: '0 12px',
fontSize: '14px',
fontWeight: 500,
letterSpacing: '0.01em',
lineHeight: '20px',
borderRadius: '6px',
cursor: 'pointer',
color: 'var(--next-error-btn-text)',
......@@ -55,34 +57,34 @@ export const errorStyles = {
border: 'var(--next-error-btn-border)',
},
buttonSecondary: {
padding: '10px 20px',
display: 'inline-flex',
alignItems: 'center',
justifyContent: 'center',
height: '32px',
padding: '0 12px',
fontSize: '14px',
fontWeight: 500,
letterSpacing: '0.01em',
lineHeight: '20px',
borderRadius: '6px',
cursor: 'pointer',
color: 'var(--next-error-btn-secondary-text)',
background: 'transparent',
border: 'none',
background: 'var(--next-error-btn-secondary-bg)',
border: 'var(--next-error-btn-secondary-border)',
},
digestContainer: {
marginTop: '20px',
paddingTop: '16px',
borderTop: 'var(--next-error-digest-border)',
},
digest: {
digestFooter: {
position: 'fixed' as const,
bottom: '32px',
left: '0',
right: '0',
textAlign: 'center' as const,
fontFamily:
'ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace',
fontSize: '12px',
lineHeight: '18px',
fontWeight: 400,
margin: '0',
color: 'var(--next-error-digest)',
},
digestCode: {
fontFamily:
'ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,monospace',
fontSize: '11px',
color: 'var(--next-error-digest-code)',
userSelect: 'all' as const,
},
} as const
export const errorThemeCss = `
......@@ -90,63 +92,46 @@ export const errorThemeCss = `
--next-error-bg: #fff;
--next-error-text: #171717;
--next-error-title: #171717;
--next-error-message: #666;
--next-error-hint: #888;
--next-error-digest: #999;
--next-error-digest-code: #888;
--next-error-digest-border: 1px solid rgba(0,0,0,0.06);
--next-error-btn-text: #171717;
--next-error-btn-bg: #fff;
--next-error-btn-border: 1px solid #e5e5e5;
--next-error-btn-secondary-text: #666;
--next-error-icon-ring: #fecaca;
--next-error-icon-fill: #fef2f2;
--next-error-message: #171717;
--next-error-digest: #666666;
--next-error-btn-text: #fff;
--next-error-btn-bg: #171717;
--next-error-btn-border: none;
--next-error-btn-secondary-text: #171717;
--next-error-btn-secondary-bg: transparent;
--next-error-btn-secondary-border: 1px solid rgba(0,0,0,0.08);
}
@media (prefers-color-scheme: dark) {
:root {
--next-error-bg: #0a0a0a;
--next-error-text: #ededed;
--next-error-title: #ededed;
--next-error-message: #a0a0a0;
--next-error-hint: #707070;
--next-error-digest: #606060;
--next-error-digest-code: #707070;
--next-error-digest-border: 1px solid rgba(255,255,255,0.08);
--next-error-btn-text: #ededed;
--next-error-btn-bg: #1a1a1a;
--next-error-btn-border: 1px solid #333;
--next-error-btn-secondary-text: #a0a0a0;
--next-error-icon-ring: #5c2121;
--next-error-icon-fill: #2a1618;
--next-error-message: #ededed;
--next-error-digest: #a0a0a0;
--next-error-btn-text: #0a0a0a;
--next-error-btn-bg: #ededed;
--next-error-btn-border: none;
--next-error-btn-secondary-text: #ededed;
--next-error-btn-secondary-bg: transparent;
--next-error-btn-secondary-border: 1px solid rgba(255,255,255,0.14);
}
}
body { margin: 0; color: var(--next-error-text); background: var(--next-error-bg); }
`.replace(/\n\s*/g, '')
export function ErrorIcon() {
export function WarningIcon() {
return (
<svg
width="40"
height="40"
viewBox="0 0 40 40"
width="32"
height="32"
viewBox="-0.2 -1.5 32 32"
fill="none"
style={errorStyles.icon}
>
<circle
cx="20"
cy="20"
r="19"
stroke="var(--next-error-icon-ring)"
strokeWidth="2"
/>
<circle cx="20" cy="20" r="16" fill="var(--next-error-icon-fill)" />
<path
d="M20 12v9"
stroke="#dc2626"
strokeWidth="2.5"
strokeLinecap="round"
d="M16.9328 0C18.0839 0.000116771 19.1334 0.658832 19.634 1.69531L31.4299 26.1309C32.0708 27.4588 31.1036 28.9999 29.6291 29H2.00215C0.527541 29 -0.439628 27.4588 0.201371 26.1309L11.9973 1.69531C12.4979 0.658823 13.5474 7.75066e-05 14.6984 0H16.9328ZM3.59493 26H28.0363L16.9328 3H14.6984L3.59493 26ZM15.8156 19C16.9202 19.0001 17.8156 19.8955 17.8156 21C17.8156 22.1045 16.9202 22.9999 15.8156 23C14.7111 23 13.8156 22.1046 13.8156 21C13.8156 19.8954 14.7111 19 15.8156 19ZM17.3156 16.5H14.3156V8.5H17.3156V16.5Z"
fill="var(--next-error-title)"
/>
<circle cx="20" cy="27" r="1.5" fill="#dc2626" />
</svg>
)
}
......@@ -2,7 +2,7 @@
import React from 'react'
import { HandleISRError } from '../handle-isr-error'
import { errorStyles, errorThemeCss, ErrorIcon } from './error-styles'
import { errorStyles, errorThemeCss, WarningIcon } from './error-styles'
export type GlobalErrorComponent = React.ComponentType<{
error: any
......@@ -14,15 +14,9 @@ function DefaultGlobalError({ error }: { error: any }) {
const digest: string | undefined = error?.digest
const isServerError = !!digest
// Server error: "This page failed to load"
// Client error: "This page crashed"
const title = isServerError ? 'This page failed to load' : 'This page crashed'
const message = isServerError
? 'Something went wrong while loading this page.'
: 'An error occurred while running this page.'
const hint = isServerError
? 'If this keeps happening, it may be a server issue.'
: null
? 'A server error occurred. Reload to try again.'
: 'Reload to try again, or go back.'
return (
<html id="__next_error__">
......@@ -33,19 +27,13 @@ function DefaultGlobalError({ error }: { error: any }) {
<HandleISRError error={error} />
<div style={errorStyles.container}>
<div style={errorStyles.card}>
<ErrorIcon />
<h1 style={errorStyles.title}>{title}</h1>
<WarningIcon />
<h1 style={errorStyles.title}>This page couldn&#x2019;t load</h1>
<p style={errorStyles.message}>{message}</p>
{hint && <p style={errorStyles.messageHint}>{hint}</p>}
{!isServerError && (
<p style={errorStyles.messageHint}>
Reloading usually fixes this.
</p>
)}
<div style={errorStyles.buttonGroup}>
<form>
<form style={errorStyles.form}>
<button type="submit" style={errorStyles.button}>
Reload page
Reload
</button>
</form>
{!isServerError && (
......@@ -60,20 +48,13 @@ function DefaultGlobalError({ error }: { error: any }) {
}
}}
>
Go back
Back
</button>
)}
</div>
{digest && (
<div style={errorStyles.digestContainer}>
<p style={errorStyles.digest}>
Error reference:{' '}
<code style={errorStyles.digestCode}>{digest}</code>
</p>
</div>
)}
</div>
</div>
{digest && <p style={errorStyles.digestFooter}>ERROR {digest}</p>}
</body>
</html>
)
......
......@@ -40,7 +40,7 @@ describe('serialize-circular-error', () => {
`)
const bodyText = await browser.elementByCss('body').text()
expect(bodyText).toContain('This page crashed')
expect(bodyText).toContain('This page couldn\u2019t load')
const output = next.cliOutput
expect(output).toContain(
......
......@@ -31,29 +31,25 @@ describe('app dir - default error page UI', () => {
// In production mode, verify the client error page UI elements
// Check that the SVG icon is present (40x40 size)
// Check that the SVG icon is present (32x32 size)
const svgIcon = await browser.elementByCss('svg')
expect(await svgIcon.getAttribute('width')).toBe('40')
expect(await svgIcon.getAttribute('height')).toBe('40')
expect(await svgIcon.getAttribute('width')).toBe('32')
expect(await svgIcon.getAttribute('height')).toBe('32')
// Check the error title - client errors show "This page crashed"
// Check the error title
const title = await browser.elementByCss('h1')
expect(await title.text()).toBe('This page crashed')
expect(await title.text()).toBe('This page couldn\u2019t load')
// Check the error message - client errors show "An error occurred while running this page."
// Check the error message - client errors show "Reload to try again, or go back."
const message = await browser.elementByCss('p')
expect(await message.text()).toContain('An error occurred while running')
expect(await message.text()).toContain('Reload to try again, or go back')
// Check the "Reload page" button exists
// Check the "Reload" button exists
const buttons = await browser.elementsByCss('button')
expect(await buttons[0].innerText()).toBe('Reload page')
expect(await buttons[0].innerText()).toBe('Reload')
// Check "Go back" button exists for client errors
expect(await buttons[1].innerText()).toBe('Go back')
// Check the hint text about reloading
const html = await browser.eval('document.documentElement.innerHTML')
expect(html).toContain('Reloading usually fixes this')
// Check "Back" button exists for client errors
expect(await buttons[1].innerText()).toBe('Back')
})
it('should reload the page when Reload page button is clicked', async () => {
......@@ -102,11 +98,11 @@ describe('app dir - default error page UI', () => {
// In light mode: #171717 = rgb(23, 23, 23)
expect(titleColor).toContain('23')
// Check that the button has neutral styling (white background with border)
// Check that the primary button has dark background
const button = await browser.elementByCss('button')
const buttonBg = await button.getComputedCss('background-color')
// White = rgb(255, 255, 255)
expect(buttonBg).toContain('255')
// Dark = rgb(23, 23, 23) (#171717)
expect(buttonBg).toContain('23')
})
it('should display server error page with Error reference', async () => {
......@@ -133,14 +129,14 @@ describe('app dir - default error page UI', () => {
// In production mode, verify the server error page
const html = await browser.eval('document.documentElement.innerHTML')
// Server errors show "This page failed to load"
expect(html).toContain('This page failed to load')
// Server errors show "This page couldn\u2019t load"
expect(html).toContain('This page couldn\u2019t load')
// Server errors show "Error reference:" with digest
expect(html).toContain('Error reference:')
// Server errors show "A server error occurred"
expect(html).toContain('A server error occurred')
// Server errors show hint about server issue
expect(html).toContain('it may be a server issue')
// Server errors show "ERROR" with digest
expect(html).toMatch(/ERROR \w+/)
})
it('should have left-aligned text in error page', async () => {
......
......@@ -190,7 +190,7 @@ describe('app-dir - errors', () => {
} else {
expect(
await browser.waitForElementByCss('body').elementByCss('h1').text()
).toBe('This page crashed')
).toBe('This page couldn\u2019t load')
}
expect(pageErrors).toEqual([
......@@ -227,10 +227,10 @@ describe('app-dir - errors', () => {
} else {
expect(
await browser.waitForElementByCss('body').elementByCss('h1').text()
).toBe('This page failed to load')
// Check digest is displayed in error reference
).toBe('This page couldn\u2019t load')
// Check digest is displayed
const bodyText = await browser.waitForElementByCss('body').text()
expect(bodyText).toMatch(/Error reference:\s*\w+/)
expect(bodyText).toMatch(/ERROR \w+/)
}
expect(pageErrors).toEqual([
......
......@@ -32,9 +32,9 @@ describe('app dir - global-error - error-in-global-error', () => {
it('should render fallback UI when error occurs in global-error', async () => {
const browser = await next.browser('/?error-in-global-error=1')
// When the custom global-error throws, it falls back to the default global-error
// Client errors show "This page crashed"
// Client errors show "This page couldn\u2019t load"
const title = await browser.elementByCss('h1').text()
expect(title).toBe('This page crashed')
expect(title).toBe('This page couldn\u2019t load')
if (isNextDev) {
await waitForRedbox(browser)
......
......@@ -36,7 +36,7 @@ describe('revalidateTag-rsc', () => {
await retry(async () => {
expect(
await browser.eval('document.documentElement.innerHTML')
).toContain('This page failed to load')
).toContain('This page couldn\u2019t load')
})
}
......
......@@ -29,9 +29,9 @@ describe('next-link', () => {
}
`)
}
// Client errors show "This page crashed"
// Client errors show "This page couldn\u2019t load"
expect(await browser.elementByCss('body').text()).toContain(
'This page crashed'
'This page couldn\u2019t load'
)
})
......@@ -54,9 +54,9 @@ describe('next-link', () => {
],
}
`)
// Client errors show "This page crashed"
// Client errors show "This page couldn\u2019t load"
expect(await browser.elementByCss('body').text()).toContain(
'This page crashed'
'This page couldn\u2019t load'
)
} else {
expect(await browser.elementByCss('body').text()).toMatchInlineSnapshot(
......
......@@ -11,8 +11,8 @@ describe('500-page app-router-only', () => {
it('should render app router 500 page when route error', async () => {
const $ = await next.render$('/route-error')
expect($('html').attr('id')).toBe('__next_error__')
// Server errors show "This page failed to load"
expect($('body').text()).toContain('This page failed to load')
// Server errors show "This page couldn\u2019t load"
expect($('body').text()).toContain('This page couldn\u2019t load')
})
}
......@@ -24,8 +24,8 @@ describe('500-page app-router-only', () => {
)
// Not use pages router to generate 500.html
expect(html).toContain('__next_error__')
// Server errors show "This page failed to load"
expect(html).toContain('This page failed to load')
// Server errors show "This page couldn\u2019t load"
expect(html).toContain('This page couldn\u2019t load')
// global-error is not used in app router 500.html
expect(html).not.toContain('app-router-global-error')
})
......
......@@ -32,8 +32,8 @@ describe('graceful-degrade - non bot', () => {
expect(await body.getAttribute('class')).not.toBe('body-cls')
const bodyText = await body.text()
// Client errors show "This page crashed"
expect(bodyText).toMatch(/This page crashed/)
// Client errors show "This page couldn\u2019t load"
expect(bodyText).toMatch(/This page couldn\u2019t load/)
})
it('should show error boundary when browser errors when error boundary is defined', async () => {
......
......@@ -31,7 +31,7 @@ describe('graceful-degrade', () => {
// Do not contain the global error boundary text
const bodyText = await originBody.text()
expect(bodyText).not.toMatch(/This page crashed/)
expect(bodyText).not.toMatch(/This page couldn\u2019t load/)
})
it('should preserve the ssr html when browser errors for bot', async () => {
......@@ -48,7 +48,7 @@ describe('graceful-degrade', () => {
expect(errors).toMatch(/Error: boom/)
const bodyText = await browser.elementByCss('body').text()
expect(bodyText).not.toMatch(/This page crashed/)
expect(bodyText).not.toMatch(/This page couldn\u2019t load/)
expect(bodyText).toMatch(/fine/)
})
})
......@@ -41,8 +41,8 @@ describe('chunk-load-failure', () => {
await retry(async () => {
const body = await browser.elementByCss('body')
// Client errors show "This page crashed"
expect(await body.text()).toMatch(/This page crashed/)
// Client errors show "This page couldn\u2019t load"
expect(await body.text()).toMatch(/This page couldn\u2019t load/)
})
expect(pageError).toBeDefined()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment