Dev Helpers
← Back

Last viewed section shortcut

Place this file at app/preferences/page.tsx in an App Router project.

Open this example in the interactive library

Source code

// app/preferences/page.tsx

import Link from "next/link";

import { cookies } from "next/headers";

export default async function LastViewedSectionShortcut() {
  const jar = await cookies();
  const saved = jar.get("last-section")?.value ?? "";
  const safe = ["guide", "studio", "projects"].includes(saved) ? saved : "guide";
  return <Link href={"/" + safe}>Resume {safe}</Link>;
}