Skip to content

Production-ready animations, transitions, backgrounds, and scenes for Remotion

feat: not-found page

kapishdima237d31552ebe
diff --git a/app/(home)/components/page-shell.tsx b/app/(home)/components/page-shell.tsx
index d99eb525..49cd032a 100644
--- a/app/(home)/components/page-shell.tsx
+++ b/app/(home)/components/page-shell.tsx
@@ -1,8 +1,20 @@
import type { ReactNode } from "react";
+import { cn } from "@/lib/utils";
-export function PageShell({ children }: { children: ReactNode }) {
+export function PageShell({
+ children,
+ className,
+}: {
+ children: ReactNode;
+ className?: string;
+}) {
return (
- <div className="page-shell relative flex min-h-screen flex-col font-sans text-foreground antialiased">
+ <div
+ className={cn(
+ "page-shell relative flex min-h-screen flex-col font-sans text-foreground antialiased",
+ className,
+ )}
+ >
{children}
</div>
);
diff --git a/app/not-found-video.tsx b/app/not-found-video.tsx
new file mode 100644
index 00000000..07e4a88a
--- /dev/null
+++ b/app/not-found-video.tsx
@@ -0,0 +1,56 @@
+"use client";
+
+import { useEffect, useRef } from "react";
+import { usePrefersReducedMotion } from "@/lib/use-prefers-reduced-motion";
+import { cn } from "@/lib/utils";
+
+const MASK = "radial-gradient(72% 78% at 50% 50%, #000 42%, transparent 100%)";
+
+function Clip({
+ theme,
+ className,
+ paused,
+}: {
+ theme: "light" | "dark";
+ className: string;
+ paused: boolean;
+}) {
+ const videoRef = useRef<HTMLVideoElement>(null);
+
+ useEffect(() => {
+ const video = videoRef.current;
+ if (!video) return;
+ if (paused) {
+ video.pause();
+ return;
+ }
+ void video.play().catch(() => {});
+ }, [paused]);
+
+ return (
+ <video
+ ref={videoRef}
+ src={`/not-found-${theme}.mp4`}
+ poster={`/not-found-${theme}.jpg`}
+ aria-label="404"
+ autoPlay
+ muted
+ loop
+ playsInline
+ preload="metadata"
+ className={cn("absolute inset-0 size-full object-cover", className)}
+ style={{ maskImage: MASK, WebkitMaskImage: MASK }}
+ />
+ );
+}
+
+export function NotFoundVideo() {
+ const reducedMotion = usePrefersReducedMotion();
+
+ return (
+ <div className="relative size-full overflow-hidden">
+ <Clip theme="light" className="dark:hidden" paused={reducedMotion} />
+ <Clip theme="dark" className="hidden dark:block" paused={reducedMotion} />
+ </div>
+ );
+}
diff --git a/app/not-found.tsx b/app/not-found.tsx
new file mode 100644
index 00000000..ec6ca9f3
--- /dev/null
+++ b/app/not-found.tsx
@@ -0,0 +1,74 @@
+import type { Metadata } from "next";
+import Link from "next/link";
+import { FadeUp } from "@/app/(home)/components/fade-up";
+import { PageShell } from "@/app/(home)/components/page-shell";
+import { SiteFooter } from "@/app/(home)/components/site-footer";
+import { SiteHeader } from "@/app/(home)/components/site-header";
+import { Button } from "@/components/ui/button";
+import { NotFoundVideo } from "./not-found-video";
+
+export const metadata: Metadata = {
+ title: "Page not found",
+ robots: { index: false, follow: true },
+};
+
+export default function NotFound() {
+ return (
+ <PageShell className="h-dvh min-h-0 overflow-hidden">
+ <div className="shrink-0">
+ <SiteHeader />
+ </div>
+
+ <main className="relative isolate flex min-h-0 flex-1 flex-col">
+ <div aria-hidden className="absolute inset-0 -z-10">
+ <div className="absolute inset-0 bg-grid-fade" />
+ </div>
+
+ <div className="min-h-0 flex-1">
+ <NotFoundVideo />
+ </div>
+
+ <div className="section shrink-0 pt-4 pb-6 sm:pt-6 sm:pb-8">
+ <div className="mx-auto flex max-w-2xl flex-col items-center text-center">
+ <FadeUp delay={0.08}>
+ <h1 className="text-balance text-3xl font-semibold leading-[1.1] tracking-tight text-foreground sm:text-4xl">
+ This page doesn't exist
+ </h1>
+ </FadeUp>
+
+ <FadeUp delay={0.14}>
+ <p className="mt-3 text-balance text-base leading-relaxed text-muted-foreground sm:text-lg">
+ The link is broken, or the page moved. The components, docs and
+ showcases are all still where you left them.
+ </p>
+ </FadeUp>
+
+ <FadeUp delay={0.2}>
+ <div className="mt-6 flex flex-col items-center gap-3 sm:flex-row">
+ <Button
+ size="lg"
+ className="rounded-full"
+ render={<Link href="/" />}
+ >
+ Back home
+ </Button>
+ <Button
+ variant="secondary"
+ size="lg"
+ className="rounded-full font-medium"
+ render={<Link href="/docs/typography" />}
+ >
+ Browse components
+ </Button>
+ </div>
+ </FadeUp>
+ </div>
+ </div>
+ </main>
+
+ <div className="shrink-0">
+ <SiteFooter />
+ </div>
+ </PageShell>
+ );
+}
diff --git a/package.json b/package.json
index e39d00ad..dd3f7aad 100644
--- a/package.json
+++ b/package.json
@@ -17,6 +17,7 @@
"remotion:browser": "bun scripts/ensure-browser.mts",
"bundle:remotion": "bun scripts/bundle-remotion.mts",
"render:demos": "bun scripts/render-demos.mts",
+ "render:not-found": "bun scripts/render-not-found.mts",
"postinstall": "fumadocs-mdx"
},
"dependencies": {
diff --git a/public/not-found-dark.jpg b/public/not-found-dark.jpg
new file mode 100644
index 00000000..c4fc0bda
Binary files /dev/null and b/public/not-found-dark.jpg differ
diff --git a/public/not-found-dark.mp4 b/public/not-found-dark.mp4
new file mode 100644
index 00000000..db063487
Binary files /dev/null and b/public/not-found-dark.mp4 differ
diff --git a/public/not-found-light.jpg b/public/not-found-light.jpg
new file mode 100644
index 00000000..2e096aa3
Binary files /dev/null and b/public/not-found-light.jpg differ
diff --git a/public/not-found-light.mp4 b/public/not-found-light.mp4
new file mode 100644
index 00000000..5539f80f
Binary files /dev/null and b/public/not-found-light.mp4 differ
diff --git a/scripts/render-not-found.mts b/scripts/render-not-found.mts
new file mode 100644
index 00000000..0de4cca5
--- /dev/null
+++ b/scripts/render-not-found.mts
@@ -0,0 +1,98 @@
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import { bundle } from "@remotion/bundler";
+import {
+ ensureBrowser,
+ renderMedia,
+ renderStill,
+ selectComposition,
+} from "@remotion/renderer";
+import { tsconfigWebpackAlias } from "./tsconfig-webpack-alias.mts";
+
+const here = path.dirname(fileURLToPath(import.meta.url));
+const root = path.resolve(here, "..");
+
+const THEMES = ["dark", "light"] as const;
+
+function remotionConcurrency(): number {
+ const parsed = Number(process.env.REMOTION_CONCURRENCY);
+ return Number.isFinite(parsed) && parsed >= 1 ? Math.floor(parsed) : 4;
+}
+
+async function main() {
+ const entryPoint = path.join(root, "src", "remotion", "not-found-root.tsx");
+ const publicDir = path.join(root, "public");
+
+ await ensureBrowser();
+
+ const tsAliases = tsconfigWebpackAlias(root);
+
+ console.log("Bundling not-found entry…");
+ const serveUrl = await bundle({
+ entryPoint,
+ webpackOverride: (config) => {
+ const existing = Object.entries(config.resolve?.alias ?? {}).map(
+ ([name, alias]) => ({
+ name: name.replace(/\$$/, ""),
+ alias: alias as string,
+ onlyModule: name.endsWith("$"),
+ }),
+ );
+ return {
+ ...config,
+ resolve: {
+ ...config.resolve,
+ alias: [...existing, ...tsAliases],
+ },
+ };
+ },
+ });
+ console.log("Bundle ready.");
+
+ const concurrency = remotionConcurrency();
+
+ for (const theme of THEMES) {
+ const inputProps = { theme };
+ const composition = await selectComposition({
+ serveUrl,
+ id: "not-found",
+ inputProps,
+ });
+
+ await renderMedia({
+ serveUrl,
+ composition,
+ codec: "h264",
+ crf: 28,
+ inputProps,
+ outputLocation: path.join(publicDir, `not-found-${theme}.mp4`),
+ concurrency,
+ chromiumOptions: { gl: "swangle" },
+ onProgress: ({ progress }) => {
+ process.stdout.write(
+ `\rnot-found-${theme}.mp4 ${Math.round(progress * 100)}% `,
+ );
+ },
+ });
+ process.stdout.write(`\rnot-found-${theme}.mp4 ✓ \n`);
+
+ await renderStill({
+ serveUrl,
+ composition,
+ frame: 0,
+ inputProps,
+ output: path.join(publicDir, `not-found-${theme}.jpg`),
+ imageFormat: "jpeg",
+ jpegQuality: 90,
+ chromiumOptions: { gl: "swangle" },
+ });
+ console.log(`not-found-${theme}.jpg ✓`);
+ }
+
+ console.log(`Done. Wrote ${THEMES.length} clip(s) + posters to public/.`);
+}
+
+main().catch((err) => {
+ console.error("\nrender-not-found failed:", err);
+ process.exit(1);
+});
diff --git a/src/remotion/not-found-root.tsx b/src/remotion/not-found-root.tsx
new file mode 100644
index 00000000..a86406f4
--- /dev/null
+++ b/src/remotion/not-found-root.tsx
@@ -0,0 +1,24 @@
+import { Composition, registerRoot } from "remotion";
+import {
+ NOT_FOUND_DURATION,
+ NOT_FOUND_FPS,
+ NOT_FOUND_HEIGHT,
+ NOT_FOUND_WIDTH,
+ NotFoundScene,
+} from "./not-found-scene";
+
+export function NotFoundRoot() {
+ return (
+ <Composition
+ id="not-found"
+ component={NotFoundScene}
+ durationInFrames={NOT_FOUND_DURATION}
+ fps={NOT_FOUND_FPS}
+ width={NOT_FOUND_WIDTH}
+ height={NOT_FOUND_HEIGHT}
+ defaultProps={{ theme: "dark" as const }}
+ />
+ );
+}
+
+registerRoot(NotFoundRoot);
diff --git a/src/remotion/not-found-scene.tsx b/src/remotion/not-found-scene.tsx
new file mode 100644
index 00000000..67a0b83b
--- /dev/null
+++ b/src/remotion/not-found-scene.tsx
@@ -0,0 +1,90 @@
+import { loadFont } from "@remotion/google-fonts/Manrope";
+import { linearTiming, TransitionSeries } from "@remotion/transitions";
+import { AbsoluteFill } from "remotion";
+import { swirlDissolve } from "@/registry/remocn/swirl-dissolve";
+
+const { fontFamily } = loadFont("normal", {
+ weights: ["600"],
+ subsets: ["latin"],
+});
+
+export type NotFoundTheme = "light" | "dark";
+
+export type NotFoundSceneProps = {
+ [key: string]: unknown;
+ theme: NotFoundTheme;
+};
+
+const PALETTE = {
+ dark: {
+ backdrop: "#111115",
+ text: "#eeeeee",
+ swirl: ["#1b1926", "#463c5e", "#d4b3ff"],
+ },
+ light: {
+ backdrop: "#ffffff",
+ text: "#0a0a0a",
+ swirl: ["#f3eefb", "#cdb9ef", "#8266b8"],
+ },
+} satisfies Record<
+ NotFoundTheme,
+ { backdrop: string; text: string; swirl: string[] }
+>;
+
+export const NOT_FOUND_FPS = 30;
+export const NOT_FOUND_WIDTH = 1920;
+export const NOT_FOUND_HEIGHT = 720;
+
+const TRANSITION_FRAMES = 90;
+const HOLD_FRAMES = 130;
+
+export const NOT_FOUND_DURATION = HOLD_FRAMES * 2 - TRANSITION_FRAMES;
+
+function Code({ color }: { color: string }) {
+ return (
+ <AbsoluteFill
+ style={{
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <span
+ style={{
+ fontFamily,
+ fontSize: 260,
+ fontWeight: 600,
+ letterSpacing: "-0.05em",
+ color,
+ }}
+ >
+ 404
+ </span>
+ </AbsoluteFill>
+ );
+}
+
+export function NotFoundScene({ theme }: NotFoundSceneProps) {
+ const { backdrop, text, swirl } = PALETTE[theme];
+
+ return (
+ <AbsoluteFill style={{ backgroundColor: backdrop }}>
+ <TransitionSeries>
+ <TransitionSeries.Sequence durationInFrames={HOLD_FRAMES}>
+ <Code color={text} />
+ </TransitionSeries.Sequence>
+ <TransitionSeries.Transition
+ timing={linearTiming({ durationInFrames: TRANSITION_FRAMES })}
+ presentation={swirlDissolve({
+ colors: swirl,
+ colorBack: backdrop,
+ bandCount: 10,
+ softness: 0.35,
+ })}
+ />
+ <TransitionSeries.Sequence durationInFrames={HOLD_FRAMES}>
+ <Code color={text} />
+ </TransitionSeries.Sequence>
+ </TransitionSeries>
+ </AbsoluteFill>
+ );
+}