๐Ÿ“ข

Check out ๐Ÿ“บ DisWidgets - ๐ŸŽจ Free, Stylish and Simple.

Custom 404 Page ๐Ÿ’ป
Next.js Custom 404 Page tutorial.
ven profile picture

Anaxes โ€ข ๐Ÿ“† Published on August 4, 2022 โ€ข ๐Ÿฟ 1 min read

Working in a Next.js product, and you accidentally enter the wrong url. Magically a bright white page appears with the words 404 ๐Ÿคฉ

๐Ÿง Solution

The simplest way to resolve this is to create a .tsx or .jsx file in the pages directory of your Next.js application, like so:

๐Ÿ’ปโ€Žโ€Ž.tsx
import React from 'react';

export const custom404 = () => {
    return (
        <h1 style={{color: "white"}}>Hello! ๐Ÿ‘‹</h1>
    );
};

export default custom404;

๐ŸŽ‰ And that's it! You now have a custom 404 page, so finally no unhappy customers :)

๐Ÿ“† Initially published: 7th of November 2021.