How can I add a custom 404 page on Vercel using vanilla Javscript?

I am not using any framework and I would like to add a custom 404 page. In Vercel’s documentation, they only provide information for users of frameworks.

>Solution :

See the documentation for Custom 404 Page – Static Site Generator (SSG)

Emit a 404.html file to your Output Directory and it will be served as the 404 page when a route does not match any other static file.

TL;DR create a 404.html file and to the root of your site and Vercel will use that to serve requests that don’t match any resources.

A static site generator like Hugo creates plain old HTML pages that (typically) don’t operate as a Single-Page Application (SPA); there’s an HTML file for each page.

This is just like a regular, non-framework, non-SPA website which matches your application structure.

Leave a Reply