404 With Redirect Countdown

404

This page does not exist

Nothing to see here. We will take you somewhere useful unless you would rather stay.

Redirecting to the homepage in 10 seconds

Go now
About this block

404 With Redirect CountdownFREE

404 page that counts down to an automatic redirect and calls onRedirect once it reaches zero, with a cancel button that stops the timer and a manual go-now link.

Error8: 404 With Redirect Countdown

A 404 page that does not wait for the visitor to act: a live countdown runs under the message and fires onRedirect when it reaches zero, with a cancel button that stops the timer for anyone who would rather stay.

Free block

This block is free. No license or account is required: install it with the CLI and use it in unlimited projects.

Installation

Radix flavor

bash
npx shadcn add "https://ui.beste.co/r/error8"

Base UI flavor

bash
npx shadcn add "https://ui.beste.co/r-base/error8"

This installs the block to components/beste/block/error8.tsx, plus the button shadcn/ui primitive it uses for the manual and cancel actions.

Quick start

The installed file exports error8Demo alongside the block: the exact props behind the preview above. Spread it and the countdown runs immediately.

tsx
import { Error8, error8Demo } from "@/components/beste/block/error8";

export default function NotFound() {
  return <Error8 {...error8Demo} />;
}

Navigation is the caller's job, so wire onRedirect to your router:

tsx
"use client";

import { useRouter } from "next/navigation";
import { Error8 } from "@/components/beste/block/error8";

export default function NotFound() {
  const router = useRouter();

  return (
    <Error8
      code="404"
      heading="This page does not exist"
      description="We will take you somewhere useful unless you would rather stay."
      seconds={10}
      labels={{
        redirect: "Redirecting to the homepage in",
        seconds: "seconds",
        cancel: "Stay on this page",
        canceled: "Automatic redirect canceled.",
      }}
      action={{ label: "Go now", href: "/" }}
      onRedirect={() => router.push("/")}
    />
  );
}

Props

PropTypeDefaultDescription
codestring–Small uppercase status label above the heading
headingstring–Main page heading, rendered as an h1
descriptionstring–Explanatory paragraph under the heading
secondsnumber–Starting value of the countdown
labelsError8Labels{}Countdown sentence, unit word, cancel button text, and canceled message
actionActionLink–Manual link button beside the cancel button
onRedirect() => void–Called once when the countdown reaches zero
classNamestring–Extra classes for the outer <section>
ts
type Error8Labels = {
  redirect?: string;
  seconds?: string;
  cancel?: string;
  canceled?: string;
};

type ActionLink = {
  label: string;
  href: string;
};

Behavior notes

  • The block never navigates on its own. It only calls onRedirect, so the caller decides between router.push, window.location, or nothing at all, and the preview above stays put.
  • onRedirect fires exactly once. A ref guards the call, so re-renders and a handler whose identity changes cannot trigger a second redirect.
  • Passing no seconds (or 0) disables the redirect entirely: the guard skips the call and the countdown never starts.
  • Pressing cancel stops the timer permanently for that mount, swaps the countdown sentence for labels.canceled, and removes the cancel button, leaving only the manual action link.
  • The countdown line is marked aria-live="polite", so screen readers hear the remaining time without the page stealing focus every second.

More Error blocks

View all Error
PRO

error25

Rate Limit Cooldown

PRO

error36

Not Found With Search

FREE

error2

404 With Site Search