Open source CapCut alternative.
TypeScript
feat(site): turn on Cache Components and validate the public pages
David Led87da5cafe3a
diff --git a/site/next.config.ts b/site/next.config.tsindex de527b67..c2a76e3f 100644--- a/site/next.config.ts+++ b/site/next.config.ts@@ -5,6 +5,15 @@ const nextConfig: NextConfig = {pageExtensions: ["js", "jsx", "ts", "tsx", "md", "mdx"],// Workspace packages ship TypeScript source; the app build transpiles them.transpilePackages: ["@donkeycut/effects-kit"],+ // Cache Components: pages prerender to a static shell and anything uncached+ // streams behind its own Suspense boundary. It is what the `unstable_instant`+ // export on the public pages and the app's home routes validates against, and+ // it puts the router's client cache on React <Activity> — a page you navigate+ // away from stays mounted hidden (up to three), with its effects torn down.+ // The editor is built for that already: it paints its loading screen until+ // the store holds this route's own project, and usePlayback disposes decoders+ // and the audio mixer from an effect cleanup.+ cacheComponents: true,// Cut (the video editor) uploads large media. Two independent limits apply:// its media route reads req.formData() (a route handler), so it isn't covered// by serverActions.bodySizeLimit; and src/proxy.ts runs on /api/cut/* on every@@ -14,6 +23,9 @@ const nextConfig: NextConfig = {experimental: {serverActions: { bodySizeLimit: "4gb" },proxyClientMaxBodySize: "4gb",+ // Dev-only DevTools panel: freeze a page load or a link click at the shell+ // the route actually prefetches, so a regression is visible while editing.+ instantNavigationDevToolsToggle: true,},// Cut is local-only: /api/cut/* 404s on a hosted deploy and never runs the// engine. But Turbopack's file tracer still follows the route's import of thediff --git a/site/src/app/cut/page.tsx b/site/src/app/cut/page.tsxindex e9be70c4..42cc8be0 100644--- a/site/src/app/cut/page.tsx+++ b/site/src/app/cut/page.tsx@@ -28,6 +28,12 @@ export const metadata: Metadata = {},};+// The public pages are the ones a visitor lands on cold, so they are the ones+// that have to be instant. Nothing here reads request data; declaring it makes+// Next check that in dev and at build, and the check is what keeps a server+// read added later from quietly turning a link click into a wait.+export const unstable_instant = { prefetch: "static" };+// The Cut marketing landing, served at "/" on every host by the proxy's// "/…" → "/cut/…" rewrite.export default function CutLandingPage() {diff --git a/site/src/app/install/page.tsx b/site/src/app/install/page.tsxindex 76c3bb6a..85526e57 100644--- a/site/src/app/install/page.tsx+++ b/site/src/app/install/page.tsx@@ -12,6 +12,8 @@ export const metadata: Metadata = {alternates: { canonical: `${DONKEYCUT_CANONICAL}/install` },};+export const unstable_instant = { prefetch: "static" };+// The install page is passed through by src/proxy.ts and wears the Cut site's// header and footer.export default function InstallPage() {diff --git a/site/src/app/privacy/page.tsx b/site/src/app/privacy/page.tsxindex 66b6c7f8..0cc608fa 100644--- a/site/src/app/privacy/page.tsx+++ b/site/src/app/privacy/page.tsx@@ -1,7 +1,7 @@import PrivacyPolicy from "@/app/legal/PrivacyPolicy.mdx";import { LegalPageShell } from "@/app/legal/LegalPageShell";-export const dynamic = "force-static";+export const unstable_instant = { prefetch: "static" };export default function PrivacyPage() {return (diff --git a/site/src/app/sign-in/page.tsx b/site/src/app/sign-in/page.tsxindex f39f4bd2..8529e327 100644--- a/site/src/app/sign-in/page.tsx+++ b/site/src/app/sign-in/page.tsx@@ -7,6 +7,8 @@ export const metadata: Metadata = {description: "Log in to Donkey with Google.",};+export const unstable_instant = { prefetch: "static" };+export default function Page() {return <AuthScreen mode="sign-in" />;}diff --git a/site/src/app/sign-up/page.tsx b/site/src/app/sign-up/page.tsxindex df664dfd..18bc0f4b 100644--- a/site/src/app/sign-up/page.tsx+++ b/site/src/app/sign-up/page.tsx@@ -7,6 +7,8 @@ export const metadata: Metadata = {description: "Create a Donkey account with Google.",};+export const unstable_instant = { prefetch: "static" };+export default function Page() {return <AuthScreen mode="sign-up" />;}diff --git a/site/src/app/terms/page.tsx b/site/src/app/terms/page.tsxindex 097197ec..f46d7b01 100644--- a/site/src/app/terms/page.tsx+++ b/site/src/app/terms/page.tsx@@ -1,7 +1,7 @@import TermsOfService from "@/app/legal/TermsOfService.mdx";import { LegalPageShell } from "@/app/legal/LegalPageShell";-export const dynamic = "force-static";+export const unstable_instant = { prefetch: "static" };export default function TermsPage() {return (diff --git a/site/src/app/unsubscribe/page.tsx b/site/src/app/unsubscribe/page.tsxindex 1a7c8704..93fd44a5 100644--- a/site/src/app/unsubscribe/page.tsx+++ b/site/src/app/unsubscribe/page.tsx@@ -1,3 +1,5 @@+import { Suspense } from "react";+import { LegalPageShell } from "@/app/legal/LegalPageShell";import { UnsubscribeConfirm } from "@/app/unsubscribe/UnsubscribeConfirm";import { verifyUnsubscribeToken } from "@/lib/email/unsubscribe";@@ -6,25 +8,39 @@ import { verifyUnsubscribeToken } from "@/lib/email/unsubscribe";// here, but the actual unsubscribe waits for a button press: link-prefetching// mail scanners open URLs on the recipient's behalf, and a GET that// unsubscribed on load would let them opt people out.-export default async function UnsubscribePage({+//+// The token is request data, so the shell — page chrome and heading — prerenders+// and the verified answer streams in behind the boundary below.+export default function UnsubscribePage({searchParams,}: {searchParams: Promise<{ token?: string }>;}) {- const { token } = await searchParams;- const userId = token ? verifyUnsubscribeToken(token) : null;-return (<LegalPageShell><h1>Email preferences</h1>- {userId && token ? (- <UnsubscribeConfirm token={token} />- ) : (- <p>- This link is no longer valid. You can manage product emails from- Settings in the app.- </p>- )}+ <Suspense fallback={<p>Checking this link…</p>}>+ <Verdict searchParams={searchParams} />+ </Suspense></LegalPageShell>);}++async function Verdict({+ searchParams,+}: {+ searchParams: Promise<{ token?: string }>;+}) {+ const { token } = await searchParams;+ const userId = token ? verifyUnsubscribeToken(token) : null;++ if (!userId || !token) {+ return (+ <p>+ This link is no longer valid. You can manage product emails from Settings+ in the app.+ </p>+ );+ }+ return <UnsubscribeConfirm token={token} />;+}