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
codestringSmall uppercase status label above the heading
headingstringMain page heading, rendered as an h1
descriptionstringExplanatory paragraph under the heading
secondsnumberStarting value of the countdown
labelsError8Labels{}Countdown sentence, unit word, cancel button text, and canceled message
actionActionLinkManual link button beside the cancel button
onRedirect() => voidCalled once when the countdown reaches zero
classNamestringExtra 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

Too-many-requests page with a square eyebrow and status code, an accent headline, three bordered usage cells, and a live cooldown counter that swaps itself for a retry seal button when it reaches zero.

PRO

error36

Not Found With Search

A not-found page that offers a way forward rather than a way back, pairing an oversized light heading with an image tile floating a live search panel and a two-column hairline list of likely destinations.

FREE

error2

404 With Site Search

Search-first 404 page: a controlled search field with a submit handler, plus a bordered list of suggested pages with titles, descriptions, and hover arrows.

PRO

error4

404 With Destination Cards

404 page that recovers the visit with a grid of destination cards, each with an icon, title, description, and hover arrow, followed by a centered row of fallback buttons.

PRO

error13

404 With Site Directory

404 page that doubles as a sitemap: left-aligned messaging over four columns of grouped section links, so visitors on a large site can jump straight to the area they wanted.

PRO

error5

404 Support Panel

Card-style 404 panel that echoes the requested URL in monospace, pairs a browser-history back button with link actions, and closes with a support and status link row.