How to create a custom 404 error page for NextJS?

Customize your 404 error page with NextJS for the brand-new App router, and make your users' experience more pleasant.
•
Updated on August 14, 2026
•
3 min read
Believemy logo

When developing websites with NextJS, it is essential to provide a pleasant experience for our users when they encounter a 404 error.

Good to know

A 404 error is an error we encounter when something does not exist or has not been found: in this case, a page on a site. 😗

Rather than displaying a generic page offered by default by NextJS, let's try to create a custom 404 page to maintain user engagement.

 

Why customize a 404 page?

As we've seen, we typically encounter a 404 error when an invalid or incorrect URL has been requested.

Here is the type of 404 error you might encounter on Believemy:

Example of a 404 error page: here on our site, Believemy
Example of a 404 error page: here on our site, Believemy

A well-thought-out 404 page allows:

  • keeping users on our website by redirecting them to relevant content;
  • adding a touch of humor to highlight the company's universe;
  • improving user experience.

 

Step 1: Create a not-found page

Warning

For the rest of this article, we will use the latest App router of NextJS.

In NextJS, we can create a 404 error page very easily: simply go to your app folder and create a not-found.jsx (or not-found.tsx if you want to use Typescript).

Here's an example for app/not-found.jsx:

JSX
// app/not-found.jsx
import Link from 'next/link';

const Custom404 = () => {
  return (
    <div>
      <h1>404. Page non trouvée</h1>
      <p>
        Il semble que la page que vous recherchez n'existe pas. Retournez à l'accueil ou explorez d'autres sections.
      </p>
      <Link href="/" >
        Retour à l'accueil
      </Link>
    </div>
  );
};

export default Custom404;

We now have our error page ready to use! Look for an invalid URL on your site: you should be able to see your new custom 404 error page.

 

Step 2: Create multiple 404 error pages

It is also interesting to create several different 404 error pages with the NextJS app router.

The idea is to offer different experiences depending on the section of the site we are on.

The advantage is that it's simple and quick thanks to the app router. It is indeed possible to have multiple not-found pages in the same project! For example:

  • app/not-found.jsx - Will be a 404 error page for all 404 errors encountered on our site
  • app/articles/not-found.jsx - Will be a 404 error page for all 404 errors encountered specifically in articles URLs.
  • app/profiles/not-found.jsx - Will be a 404 error page for all 404 errors encountered specifically in profiles URLs.

In short, you get the idea!

 

Conclusion

Creating a custom 404 error page with Next.js is an important step in offering a consistent and attractive user experience: well-designed, this page can not only minimize user frustration but also reinforce the image of your site.

In summary:

  1. Create a not-found.jsx file in the app folder
  2. Add links and animations
  3. Think about creating 404 pages dedicated to certain parts of your site

And to go even further, consider checking out our complete training on NextJS. ✨

Homepage of our complete NextJS training
Homepage of our complete NextJS training
Category: Developers

Share this article

Want to help us? Share this article on your networks or even better: on your site, in an article or in your newsletter.

Believemy logo
Comments (0)

You need to be logged in to comment on this article: log in or sign up.

Read next

How do I add a favicon with NextJS?

Learn how to easily add a favicon to your NextJS project with this detailed guide and also find out how to generate a favicon on demand using ImageResponse.

December 6, 2024

What's new in NextJS 15

NextJS 15 was presented to the world on October 24, 2024 in San Francisco. Here's everything we know about NextJS 15's powerful new features!

December 5, 2024

Understanding .env files with ReactJS

Find out how to really use the .env file with React or NextJS so you never make a mistake again.

December 9, 2024

Implementing over-request revalidation with NextJS

If you're a web developer, you probably know how important it is to have a fast, responsive site to deliver an optimal user experience. In this article, we're going to show you how to set up on-demand revalidation with NextJS, a feature that refreshes your site's data only when necessary. Using this method, you can save resources and improve the performance of your website, while offering up-to-date data to your users.

December 9, 2024

Setting up a loader when changing a Nextjs page

Have you ever been on a site where you click on a link and nothing happens? Or perhaps you've wondered whether your request was actually received? This is where having a loader comes in. In this article, we'll explain why it's important to have a loader on your website, how to set it up in your Nextjs project and create a function that will display the loader until the page is loaded. If you want to improve the user experience on your website and reassure your visitors, this article is for you.

December 11, 2024

React vs NextJS: what should you choose for your project in 2025?

Which technology should you use, React or NextJS? Discover their advantages and disadvantages to choose the one best suited to your projects.

December 9, 2024

Create a clean, modern timeline using html and css

Whether you want to show a purchasing process, the highlights of your career on your portfolio, or anything else, learn how to create a sleek, modern timeline to show it off!

December 9, 2024

How to use Server Actions with NextJS

Discover why and how NextJS Server Actions improve performance on both Client Components and Server Components, and learn how to use them in your projects.

December 9, 2024

Become the solopreneur you dream of being.

First project, career change, business launch: access our courses, practice on real-world cases, and move forward with clear guidance.