Newsletter
Join the Community
Subscribe to our newsletter for the latest news and updates
Next.js example that serves custom 5xx error pages from static HTML files in the public directory on Vercel.
Custom Error Pages (Static HTML) is a Next.js boilerplate from Vercel that demonstrates how to serve branded 5xx server error pages using static HTML files placed in the public directory. This example deploys to Vercel and requires an Enterprise plan to use the underlying custom error page feature.
This example is a minimal Next.js application with a public/ folder containing two files: 500.html, a generic server error fallback, and 504.html, a specific gateway timeout page. When the project is deployed to Vercel, the platform automatically detects these files and routes matching 5xx HTTP error codes to them. The repository includes a one-click deploy link and instructions to clone it locally with pnpm create-next-app.
After deployment, Vercel inspects the public directory for files named after HTTP status codes, such as 500.html and 504.html. It then generates routing rules that serve these files whenever the corresponding server error occurs. If a specific code (like 502 or 503) does not have its own file, Vercel falls back to the generic 500.html page.
The custom error page feature is only available on Vercel's Enterprise plan. The example code itself is open source, but using it to replace platform error pages requires an Enterprise upgrade.
You can create a file for any 5xx status code. The included example provides 500.html and 504.html, and Vercel will use 500.html as a fallback for other codes such as 502, 503, and 508.
Yes. Clone the repository with pnpm create-next-app and run pnpm dev to see a standard Next.js app. The custom error pages only take effect when deployed to Vercel, since they rely on the platform's error-page detection.
Use the one-click deploy button to create a Vercel project directly, or clone the repository with pnpm create-next-app --example, then push to a Git provider and import it into Vercel.
