Skip to content

Open source CapCut alternative.

TypeScript

feat(site): gate Cut landing CTAs on session

David Le914fae708f2c
diff --git a/site/src/app/_components/landing/TopNav.tsx b/site/src/app/_components/landing/TopNav.tsx
index b8f980d1..b473a428 100644
--- a/site/src/app/_components/landing/TopNav.tsx
+++ b/site/src/app/_components/landing/TopNav.tsx
@@ -21,6 +21,9 @@ type Props = {
// Signed-in pill into the product. The Cut landing points it at the Cut
// projects home, which lives under a different base per host.
signedInPill?: { href: string; label: string };
+ // Signed-out pill into auth. The Cut landing shows a "Log in" pill here (the
+ // sign-in screen offers "Create account"), so the nav has a visible way in.
+ signedOutPill?: { href: string; label: string };
};
export function TopNav({
@@ -28,6 +31,7 @@ export function TopNav({
wordmark = "Donkey",
authToggle,
signedInPill = { href: "/app", label: "Dashboard" },
+ signedOutPill,
}: Props) {
// Signed-in visitors don't need the auth links or the download CTA; the whole
// right cluster collapses to a single white button into the product. During the
@@ -79,6 +83,10 @@ export function TopNav({
<PillButton href={signedInPill.href} variant="secondary" size="sm">
{signedInPill.label}
</PillButton>
+ ) : signedOutPill ? (
+ <PillButton href={signedOutPill.href} variant="secondary" size="sm">
+ {signedOutPill.label}
+ </PillButton>
) : authToggle ? (
<Link
href={authToggle.href}
diff --git a/site/src/app/_components/landing/useAppEntryHref.ts b/site/src/app/_components/landing/useAppEntryHref.ts
new file mode 100644
index 00000000..12726c5a
--- /dev/null
+++ b/site/src/app/_components/landing/useAppEntryHref.ts
@@ -0,0 +1,21 @@
+"use client";
+
+import { authClient } from "@/lib/auth-client";
+
+// Sign-in lives at the root-level /sign-in on the auth-owning host (donkeycut.com
+// owns auth directly), and the AuthScreen there already offers a "Create account"
+// toggle — so one sign-in link covers both "log in" and "sign up". The app target
+// (already root-prefixed for the host) rides along as the post-auth callback.
+export function signInHrefFor(appTarget: string): string {
+ return `/sign-in?callbackURL=${encodeURIComponent(appTarget)}`;
+}
+
+// Where a landing CTA should actually go: straight into the app when signed in,
+// or to sign-in when signed out. During the initial (pending) client render the
+// session is unknown, matching the static server HTML, so CTAs render the app
+// target first and swap to the sign-in link once a signed-out session resolves.
+export function useAppEntryHref(): (appTarget: string) => string {
+ const { data: session, isPending } = authClient.useSession();
+ return (appTarget: string) =>
+ isPending || session ? appTarget : signInHrefFor(appTarget);
+}
diff --git a/site/src/app/cut/_components/landing/CutFinalCTA.tsx b/site/src/app/cut/_components/landing/CutFinalCTA.tsx
index f856be86..be818782 100644
--- a/site/src/app/cut/_components/landing/CutFinalCTA.tsx
+++ b/site/src/app/cut/_components/landing/CutFinalCTA.tsx
@@ -1,8 +1,11 @@
"use client";
import { PillButton } from "@/app/_components/landing/LandingPrimitives";
+import { useAppEntryHref } from "@/app/_components/landing/useAppEntryHref";
export function CutFinalCTA({ root }: { root: string }) {
+ const appHref = useAppEntryHref();
+
return (
<section
id="download"
@@ -21,7 +24,7 @@ export function CutFinalCTA({ root }: { root: string }) {
Installs in 90 seconds.
</p>
<div className="flex justify-center">
- <PillButton href={`${root}/app`} variant="primary" size="lg">
+ <PillButton href={appHref(`${root}/app`)} variant="primary" size="lg">
Start Today
</PillButton>
</div>
diff --git a/site/src/app/cut/_components/landing/CutHero.tsx b/site/src/app/cut/_components/landing/CutHero.tsx
index e8ce4aa8..fa28a822 100644
--- a/site/src/app/cut/_components/landing/CutHero.tsx
+++ b/site/src/app/cut/_components/landing/CutHero.tsx
@@ -1,9 +1,12 @@
"use client";
import { PillButton } from "@/app/_components/landing/LandingPrimitives";
+import { useAppEntryHref } from "@/app/_components/landing/useAppEntryHref";
import { EditorMock } from "@/app/cut/_components/landing/editor-mock/EditorMock";
export function CutHero({ root }: { root: string }) {
+ const appHref = useAppEntryHref();
+
return (
<section
id="top"
@@ -21,7 +24,7 @@ export function CutHero({ root }: { root: string }) {
subscriptions.
</p>
<div className="mt-12">
- <PillButton href={`${root}/app`} variant="primary" size="md">
+ <PillButton href={appHref(`${root}/app`)} variant="primary" size="md">
Start a new project
</PillButton>
</div>
diff --git a/site/src/app/cut/_components/landing/CutLanding.tsx b/site/src/app/cut/_components/landing/CutLanding.tsx
index 1382c2a2..2e5b4c2e 100644
--- a/site/src/app/cut/_components/landing/CutLanding.tsx
+++ b/site/src/app/cut/_components/landing/CutLanding.tsx
@@ -1,6 +1,7 @@
"use client";
import { TopNav } from "@/app/_components/landing/TopNav";
+import { signInHrefFor } from "@/app/_components/landing/useAppEntryHref";
import { BG, BLACK } from "@/app/_components/landing/theme";
import { CutFinalCTA } from "@/app/cut/_components/landing/CutFinalCTA";
import { CutFooter } from "@/app/cut/_components/landing/CutFooter";
@@ -11,9 +12,9 @@ import { CutWorksWith } from "@/app/cut/_components/landing/CutWorksWith";
// The donkeycut.com marketing page: the Donkey landing's cream visual system
// with Cut-only content. `root` is "" on donkeycut.com and "/cut" in dev, so
-// links into the app resolve on either host. The nav carries no auth entry
-// points — sign-in happens through the app's own surfaces (signInUrl) — while
-// the signed-in "Go to App" pill points at the Cut projects home on either host.
+// links into the app resolve on either host. Every CTA into the app is gated on
+// session (useAppEntryHref): signed-out clicks route to sign-in first. The nav
+// mirrors this — a "Log in" pill when signed out, "Go to App" when signed in.
export function CutLanding({ root }: { root: string }) {
return (
<main
@@ -29,6 +30,7 @@ export function CutLanding({ root }: { root: string }) {
homeHref={root || "/"}
wordmark="Donkey Cut"
signedInPill={{ href: `${root}/app`, label: "Go to App" }}
+ signedOutPill={{ href: signInHrefFor(`${root}/app`), label: "Log in" }}
/>
<CutHero root={root} />
<CutWorksWith />
diff --git a/site/src/app/cut/_components/landing/CutPricing.tsx b/site/src/app/cut/_components/landing/CutPricing.tsx
index 6cbd41e4..952516d3 100644
--- a/site/src/app/cut/_components/landing/CutPricing.tsx
+++ b/site/src/app/cut/_components/landing/CutPricing.tsx
@@ -2,11 +2,20 @@
import { Headline } from "@/app/_components/landing/LandingPrimitives";
import { PricingPlanCard } from "@/app/_components/landing/PricingPlanCard";
+import { useAppEntryHref } from "@/app/_components/landing/useAppEntryHref";
import { useMediaQuery } from "@/app/_components/landing/useMediaQuery";
import { cutPricingPlans } from "@/app/cut/_components/landing/cutPricingPlans";
export function CutPricing({ root }: { root: string }) {
const isDesktop = useMediaQuery("(min-width: 768px)");
+ const appHref = useAppEntryHref();
+
+ // Both plan CTAs enter the app, so gate them the same way as the hero: a
+ // signed-out click lands on sign-in first, then returns to the app target.
+ const plans = cutPricingPlans(root).map((plan) => ({
+ ...plan,
+ action: { ...plan.action, href: appHref(plan.action.href) },
+ }));
return (
<section
@@ -34,7 +43,7 @@ export function CutPricing({ root }: { root: string }) {
gap: 24,
}}
>
- {cutPricingPlans(root).map((plan) => (
+ {plans.map((plan) => (
<PricingPlanCard key={plan.name} plan={plan} />
))}
</div>