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.

Added suspense boundaries

Steven Tey4739b05001f2
diff --git a/app/dub.sh/page.tsx b/app/dub.sh/page.tsx
index 04eab32b48..ab740173bd 100644
--- a/app/dub.sh/page.tsx
+++ b/app/dub.sh/page.tsx
@@ -1,12 +1,14 @@
import Demo from "#/ui/home/demo";
import Globe from "#/ui/home/globe";
-import Stats from "#/ui/home/stats";
+import Stats, { StatsSection } from "#/ui/home/stats";
import Features from "#/ui/home/features";
import Hero from "#/ui/home/hero";
import Logos from "#/ui/home/logos";
-import OSS from "#/ui/home/oss";
+import OSS, { OSSSection } from "#/ui/home/oss";
import Testimonials from "#/ui/home/testimonials";
import Changelog from "#/ui/home/changelog";
+import { Suspense } from "react";
+import GlobeClient from "#/ui/home/globe-client";
export default function Home() {
return (
@@ -14,12 +16,24 @@ export default function Home() {
<Hero />
<Demo />
<Logos />
- <Globe />
- <Stats />
+ <Suspense fallback={<GlobeClient markers={[]} />}>
+ <Globe />
+ </Suspense>
+ <Suspense
+ fallback={
+ <StatsSection domains={1000} shortlinks={20000} clicks={3500000} />
+ }
+ >
+ <Stats />
+ </Suspense>
<Features />
- <Testimonials />
+ <Suspense>
+ <Testimonials />
+ </Suspense>
<Changelog />
- <OSS />
+ <Suspense fallback={<OSSSection stars={10000} />}>
+ <OSS />
+ </Suspense>
</>
);
}
diff --git a/app/ui/home/oss.tsx b/app/ui/home/oss.tsx
index 957e3ea827..57b8e71078 100644
--- a/app/ui/home/oss.tsx
+++ b/app/ui/home/oss.tsx
@@ -20,6 +20,10 @@ export default async function OSS() {
},
).then((res) => res.json());
+ return <OSSSection stars={stars} />;
+}
+
+export function OSSSection({ stars }: { stars: number }) {
return (
<div className="mt-20 border-t border-gray-200 bg-white/10 py-20 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.2)] backdrop-blur">
<MaxWidthWrapper>
diff --git a/app/ui/home/stats.tsx b/app/ui/home/stats.tsx
index 5720e19aeb..e7514e3db1 100644
--- a/app/ui/home/stats.tsx
+++ b/app/ui/home/stats.tsx
@@ -1,4 +1,3 @@
-import { unstable_cache } from "next/cache";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
import { nFormatter } from "#/lib/utils";
import { getTotalVerifiedDomains, getTotalLinks } from "#/lib/planetscale";
@@ -23,6 +22,20 @@ export default async function Stats() {
.then((res) => res.json())
.then((res) => res.data[0]["count(timestamp)"]);
+ return (
+ <StatsSection domains={domains} shortlinks={shortlinks} clicks={clicks} />
+ );
+}
+
+export function StatsSection({
+ domains,
+ shortlinks,
+ clicks,
+}: {
+ domains: number;
+ shortlinks: number;
+ clicks: number;
+}) {
return (
<div className="border-y border-gray-200 bg-white/10 py-8 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.2)] backdrop-blur">
<MaxWidthWrapper className="grid gap-y-4 divide-x divide-gray-200 md:grid-cols-3 md:gap-y-0">
diff --git a/app/ui/home/testimonials.tsx b/app/ui/home/testimonials.tsx
index 954f9d9c14..ae022d1549 100644
--- a/app/ui/home/testimonials.tsx
+++ b/app/ui/home/testimonials.tsx
@@ -1,4 +1,3 @@
-import { unstable_cache } from "next/cache";
import { nFormatter } from "#/lib/utils";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
import TestimonialsMobile from "./testimonials-mobile";