Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Customize deepview page (#3946)

Steven Teyfa70f180de37
diff --git a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/action-buttons.tsx b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/action-buttons.tsx
index 63e37197e9..2bce7df50b 100644
--- a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/action-buttons.tsx
+++ b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/action-buttons.tsx
@@ -2,15 +2,18 @@
import { Link } from "@dub/prisma/client";
import { Button, useCopyToClipboard } from "@dub/ui";
+import { cn } from "@dub/utils";
import { useSearchParams } from "next/navigation";
import { getTranslations, Language } from "./translations";
export function DeepLinkActionButtons({
link,
language,
+ buttonClassnames,
}: {
link: Pick<Link, "shortLink">;
language: Language;
+ buttonClassnames?: string;
}) {
const t = getTranslations(language);
const searchParams = useSearchParams();
@@ -28,7 +31,7 @@ export function DeepLinkActionButtons({
return (
<Button
text={t.openInApp}
- className="h-12 w-full rounded-xl bg-neutral-900 text-white"
+ className={cn("h-12 w-full font-medium text-white", buttonClassnames)}
onClick={handleClick}
/>
);
diff --git a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge.tsx b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge.tsx
index f89b234381..1e550a0a82 100644
--- a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge.tsx
+++ b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/brand-logo-badge.tsx
@@ -1,31 +1,26 @@
"use client";
import { Link } from "@dub/prisma/client";
-import { useCopyToClipboard } from "@dub/ui";
import { getApexDomain, GOOGLE_FAVICON_URL } from "@dub/utils";
export function BrandLogoBadge({
link,
+ appName,
}: {
link: Pick<Link, "shortLink" | "url">;
+ appName?: string;
}) {
- const [_copied, copyToClipboard] = useCopyToClipboard();
-
return (
- <button
- onClick={async () => {
- await copyToClipboard(link.shortLink);
- window.location.href = `${link.shortLink}?skip_deeplink_preview=1`;
- }}
- className="inline-flex items-center gap-2 rounded-full bg-white px-3 py-1.5 shadow-lg shadow-black/10 ring-1 ring-neutral-200"
- >
- <img
- src={`${GOOGLE_FAVICON_URL}${getApexDomain(link.url)}`}
- className="size-8 shrink-0 overflow-visible rounded-full p-px"
- />
+ <div className="flex flex-col items-center justify-center gap-4">
+ <div className="rounded-2xl border border-neutral-100 bg-white p-6 shadow-lg">
+ <img
+ src={`${GOOGLE_FAVICON_URL}${getApexDomain(link.url)}`}
+ className="size-8 shrink-0 overflow-visible rounded-full p-px"
+ />
+ </div>
<div className="pr-1.5 text-lg font-semibold text-neutral-900">
- {getApexDomain(link.url)}
+ {appName ?? getApexDomain(link.url)}
</div>
- </button>
+ </div>
);
}
diff --git a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/page.tsx b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/page.tsx
index 37e2a4243b..e8e6c77696 100644
--- a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/page.tsx
+++ b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/page.tsx
@@ -95,6 +95,18 @@ export default async function DeepLinkPreviewPage(props: {
redirect(`https://${domain}`);
}
+ const {
+ hidePoweredByBadge = false,
+ appName,
+ variant = "default",
+ buttonClassnames,
+ } = deepViewData ?? {};
+
+ const description = t.description.replace(
+ "{appName}",
+ appName ?? t.appNameFallback,
+ );
+
return (
<>
{domain === "pliab.ly" && (
@@ -143,43 +155,56 @@ export default async function DeepLinkPreviewPage(props: {
</div>
<div className="relative z-10 flex flex-1 flex-col px-8 py-8">
- <div className="flex justify-center">
- <Link
- href="https://dub.co/docs/concepts/deep-links/quickstart"
- target="_blank"
- className={cn(
- "flex items-center gap-1 whitespace-nowrap text-sm font-medium text-neutral-900",
- t["poweredByOrder"] === "inverted" ? "flex-row-reverse" : "",
- )}
- >
- {t.poweredBy} <Wordmark className="text-content-emphasis h-3.5" />
- </Link>
- </div>
+ {!hidePoweredByBadge && (
+ <div className="flex justify-center">
+ <Link
+ href="https://dub.co/docs/concepts/deep-links/quickstart"
+ target="_blank"
+ className={cn(
+ "flex items-center gap-1 whitespace-nowrap text-sm font-medium text-neutral-900",
+ t["poweredByOrder"] === "inverted" ? "flex-row-reverse" : "",
+ )}
+ >
+ {t.poweredBy}{" "}
+ <Wordmark className="text-content-emphasis h-3.5" />
+ </Link>
+ </div>
+ )}
<div className="flex flex-1 flex-col justify-center gap-12">
- <div className="flex flex-col items-center gap-y-6">
- <BrandLogoBadge link={link} />
+ <div className="flex flex-col items-center gap-y-4">
+ <BrandLogoBadge link={link} appName={appName} />
- <div className="flex h-40 w-full max-w-xs flex-col gap-6 rounded-xl border border-neutral-300 px-10 py-8">
- <p className="text-center text-sm font-normal leading-5 text-neutral-700">
- {t.description}
+ {variant === "minimal" ? (
+ <p className="text-pretty text-center leading-5 text-neutral-500">
+ {description}
</p>
-
- <div className="flex items-center justify-center gap-3">
- <Copy className="text-content-default size-6" />
- <ArrowRight className="text-content-subtle size-3" />
- {platform === "android" ? (
- <AndroidLogo className="text-content-default size-6" />
- ) : (
- <IOSAppStore className="text-content-default size-6" />
- )}
- <ArrowRight className="text-content-subtle size-3" />
- <MobilePhone className="text-content-default size-6" />
+ ) : (
+ <div className="flex h-40 w-full max-w-xs flex-col gap-6 rounded-xl border border-neutral-300 px-10 py-8">
+ <p className="text-pretty text-center text-sm leading-5 text-neutral-600">
+ {description}
+ </p>
+
+ <div className="flex items-center justify-center gap-3">
+ <Copy className="text-content-default size-6" />
+ <ArrowRight className="text-content-subtle size-3" />
+ {platform === "android" ? (
+ <AndroidLogo className="text-content-default size-6" />
+ ) : (
+ <IOSAppStore className="text-content-default size-6" />
+ )}
+ <ArrowRight className="text-content-subtle size-3" />
+ <MobilePhone className="text-content-default size-6" />
+ </div>
</div>
- </div>
+ )}
</div>
- <DeepLinkActionButtons link={link} language={language} />
+ <DeepLinkActionButtons
+ link={link}
+ language={language}
+ buttonClassnames={buttonClassnames}
+ />
</div>
</div>
</main>
diff --git a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/translations.ts b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/translations.ts
index 9a941c98e2..c706548090 100644
--- a/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/translations.ts
+++ b/apps/web/app/app.dub.co/(deeplink)/deeplink/[domain]/[[...key]]/translations.ts
@@ -1,30 +1,51 @@
export const translations = {
en: {
poweredBy: "Powered by",
- description: "Clicking below will copy this page and open it in the app.",
+ description: "Click below to open the page in {appName}.",
+ appNameFallback: "the application",
openInApp: "Open in the app",
},
zh: {
poweredBy: "由",
- description: "点击下方将复制此页面并在应用中打开。",
+ description: "点击下方在 {appName} 中打开页面。",
+ appNameFallback: "应用",
openInApp: "在应用中打开",
},
es: {
poweredBy: "Desarrollado por",
- description:
- "Al hacer clic a continuación, se copiará esta página y se abrirá en la aplicación.",
+ description: "Haz clic abajo para abrir la página en {appName}.",
+ appNameFallback: "la aplicación",
openInApp: "Abrir en la aplicación",
},
fr: {
poweredBy: "Propulsé par",
- description:
- "En cliquant ci-dessous, cette page sera copiée et ouverte dans l'application.",
+ description: "Cliquez ci-dessous pour ouvrir la page dans {appName}.",
+ appNameFallback: "l'application",
openInApp: "Ouvrir dans l'application",
},
+ it: {
+ poweredBy: "Offerto da",
+ description: "Clicca qui sotto per aprire la pagina in {appName}.",
+ appNameFallback: "l'applicazione",
+ openInApp: "Apri nell'app",
+ },
+ pt: {
+ poweredBy: "Desenvolvido por",
+ description: "Clique abaixo para abrir a página no {appName}.",
+ appNameFallback: "o aplicativo",
+ openInApp: "Abrir no aplicativo",
+ },
+ de: {
+ poweredBy: "Bereitgestellt von",
+ description: "Klicke unten, um die Seite in {appName} zu öffnen.",
+ appNameFallback: "der App",
+ openInApp: "In der App öffnen",
+ },
tr: {
poweredBy: "tarafından desteklenmektedir",
poweredByOrder: "inverted",
- description: "Linki uygulamada açmak için aşağıdaki butona tıklayın.",
+ description: "Sayfayı {appName} içinde açmak için aşağıya tıklayın.",
+ appNameFallback: "uygulama",
openInApp: "Uygulamada aç",
},
} as const;
diff --git a/apps/web/lib/zod/schemas/deep-links.ts b/apps/web/lib/zod/schemas/deep-links.ts
index f58bfbb9e7..857740d9fe 100644
--- a/apps/web/lib/zod/schemas/deep-links.ts
+++ b/apps/web/lib/zod/schemas/deep-links.ts
@@ -2,7 +2,9 @@ import * as z from "zod/v4";
export const deepViewDataSchema = z
.object({
- ios: z.any(),
- android: z.any(),
+ hidePoweredByBadge: z.boolean().optional(),
+ appName: z.string().trim().min(1).optional(),
+ variant: z.enum(["default", "minimal"]).default("default"),
+ buttonClassnames: z.string().trim().min(1).optional(),
})
.nullish();