Not Found Page for React

Animated 404 page with subtle icon motion and reduced-motion support.

Component

Installation

 

Usage

Import

Add the NotFoundPage import.

import { NotFoundPage } from "@/components/not-found-page";

Use

Use in app/not-found.tsx.

export default function NotFound() {
  return <NotFoundPage />;
}

Guidelines

  • Use in app/not-found.tsx (Next.js App Router) for the 404 route.
  • Requires next/link; ensure you are in a Next.js project.
  • Icon wobble animation on 404 page.

Props

All props are optional unless marked required. Use these to customize every aspect of the component.

PropTypeDefaultDescription
classNamestring-Additional CSS classes.
homeHrefstring"/"URL for the back/home link.
titlestring"404"Main heading text.
descriptionstring"Oops! Page not found"Subheading text.
helperTextstring"The page you are looking for..."Helper paragraph text below the description.
backLabelstring"Back to Home"Label for the back link.
iconReact.ReactNode<Frown />Custom icon rendered above the title. Accepts any React element - lucide icon, SVG, or emoji.
buttonClassNamestring-Additional CSS classes for the back/home button.

Accessibility

  • The only interactive control is a next/link styled as a button, so it is natively keyboard focusable and operable with Enter.
  • Focus visibility relies on the browser default outline since no custom focus-visible ring is defined; consider adding one to match the button styling.
  • The heading uses a semantic h1 and the link contains visible text from backLabel, so its purpose is announced to screen readers without extra labels.
  • No explicit ARIA roles, aria-label, or live-region announcements are present; the layout depends on visible text and heading semantics alone.
  • Reduced motion is honoured via useReducedMotion, which disables the entrance fade-and-slide and the continuous icon wobble for users who prefer reduced motion.

Performance

  • Animations are limited to opacity and CSS transform (translateY and rotate), which are compositor-friendly and avoid layout or paint thrashing.
  • The icon wobble runs as an infinite Framer Motion loop driven by requestAnimationFrame, so it keeps running while mounted but stays on the GPU-accelerated transform property.
  • When prefers-reduced-motion is set, durations collapse to zero and the infinite repeat is removed, eliminating ongoing animation work.
  • Framer Motion manages its own animation lifecycle and cleanup on unmount, so there are no manual timers, listeners, or observers to leak.
  • This is a small client component with no data fetching or state beyond the reduced-motion check, keeping its runtime cost minimal.

Examples

Basic

Use in app/not-found.tsx for Next.js App Router.

import { NotFoundPage } from "@/components/not-found-page";

export default function NotFound() {
  return <NotFoundPage />;
}

Custom text

Customize text and home link.

import { NotFoundPage } from "@/components/not-found-page";

export default function NotFound() {
  return (
    <NotFoundPage
      homeHref="/"
      title="404"
      description="Page not found"
      backLabel="Go home"
    />
  );
}

Custom icon

Pass any React element as the icon - a lucide icon, custom SVG, or emoji.

import { Ghost } from "lucide-react";
import { NotFoundPage } from "@/components/not-found-page";

export default function NotFound() {
  return (
    <NotFoundPage
      icon={
        <Ghost className="mx-auto h-24 w-24 text-muted-foreground" />
      }
    />
  );
}

Last updated on Jun 25

Made with ❤️ by Pulkit &

© 2026 Pulkit. All rights reserved

Last updated: