Skip to content

Open-source status page, incident response and uptime monitoring

feat: status-page iframe (#2077)

Maximilian Kasked14187b42f9c
diff --git a/apps/docs/astro.config.mjs b/apps/docs/astro.config.mjs
index 49241a21b..882575959 100644
--- a/apps/docs/astro.config.mjs
+++ b/apps/docs/astro.config.mjs
@@ -165,6 +165,10 @@ export default defineConfig({
label: "How to translate your status page",
slug: "guides/how-to-translate-status-page",
},
+ {
+ label: "How to embed a status page in an iframe",
+ slug: "guides/how-to-embed-status-page-iframe",
+ },
],
},
{
diff --git a/apps/docs/src/content/docs/guides/how-to-embed-status-page-iframe.mdx b/apps/docs/src/content/docs/guides/how-to-embed-status-page-iframe.mdx
new file mode 100644
index 000000000..bb5471d3e
--- /dev/null
+++ b/apps/docs/src/content/docs/guides/how-to-embed-status-page-iframe.mdx
@@ -0,0 +1,84 @@
+---
+title: How to Embed a Status Page in an Iframe
+description: Embed a trimmed, chromeless version of your openstatus status page on any website using the `?embed` query parameter.
+---
+
+## Problem
+
+You want to embed your openstatus status page in your marketing site, dashboard, or docs — without the full header, footer, and navigation that the standalone page includes.
+
+## Solution
+
+Append `?embed` to your status page URL to render a chromeless version suitable for embedding. Use the value to choose exactly which sections to show.
+
+## URL contract
+
+```
+https://<your-slug>.openstatus.dev/?embed=<sections>
+```
+
+- The **presence** of `?embed` turns on embed mode. The header, navigation, and subscribe form are hidden. Non-whitelabel pages keep a compact "powered by openstatus.dev" attribution; whitelabel pages hide the footer entirely.
+- The **value** is a comma-separated list of sections to show.
+- An **empty value** (`?embed` or `?embed=`) shows all sections.
+
+### Sections
+
+| Key | Renders |
+|---|---|
+| `title` | Page title + description |
+| `banner` | Current incident / maintenance banner |
+| `components` | Component health trackers |
+| `feed` | Past status reports and maintenances |
+
+Unknown keys are silently ignored. Section names are case-insensitive. If nothing valid is provided (e.g. `?embed=,` or `?embed=unknown`), all sections are shown.
+
+Section keys apply to the **root status page URL only**. Other routes (`/monitors`, `/events`, `/events/report/:id`) accept `?embed` to hide header/footer chrome, but their content is unchanged — they render normally inside the frame.
+
+### Additional parameters
+
+| Param | Values | Behavior |
+|---|---|---|
+| `theme` | `light`, `dark` | Forces the theme. Honored only when `?embed` is present. Falls back to system preference, then the page's configured default. |
+
+## Examples
+
+Show the full chromeless page:
+
+```html
+<iframe
+ src="https://status.example.com/?embed"
+ width="100%"
+ height="600"
+ style="border: 0;"
+></iframe>
+```
+
+Show only the title and current banner:
+
+```html
+<iframe
+ src="https://status.example.com/?embed=title,banner"
+ width="100%"
+ height="300"
+ style="border: 0;"
+></iframe>
+```
+
+Show components in forced dark theme:
+
+```html
+<iframe
+ src="https://status.example.com/?embed=components&theme=dark"
+ width="100%"
+ height="400"
+ style="border: 0;"
+></iframe>
+```
+
+## Notes and caveats
+
+- **Height:** iframes do not auto-size to their content. Set a `height` attribute appropriate for the sections you enabled.
+- **Internal links** (e.g. clicking an incident banner) open in a new tab when embedded, so your site's iframe stays put.
+- **Password-protected status pages** may not authenticate correctly inside iframes due to browser third-party cookie restrictions (Safari ITP, Chrome). Visitors may need to authenticate on the full status page first.
+- **Attribution:** non-whitelabel pages show a centered "powered by openstatus.dev" link in the embed footer. Whitelabel pages hide the footer entirely.
+- **Sandboxed iframes** must include at least `allow-scripts allow-same-origin` for the status page to run, plus `allow-popups` for the "open in new tab" behavior on internal links.
diff --git a/apps/status-page/next.config.ts b/apps/status-page/next.config.ts
index a881d4736..8c51b2799 100644
--- a/apps/status-page/next.config.ts
+++ b/apps/status-page/next.config.ts
@@ -14,7 +14,7 @@ const cspHeader = `
object-src 'none';
base-uri 'self';
form-action 'self';
- frame-ancestors 'none';
+ frame-ancestors *;
connect-src 'self' https://*.ingest.us.sentry.io;
worker-src 'self' blob:;
upgrade-insecure-requests;
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(auth)/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(auth)/layout.tsx
index e94252f4a..1d777d8c3 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(auth)/layout.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(auth)/layout.tsx
@@ -1,5 +1,7 @@
+import { EmbedShell } from "@/components/layout/embed-shell";
import { Footer } from "@/components/nav/footer";
import { getQueryClient, trpc } from "@/lib/trpc/server";
+import { cn } from "@openstatus/ui/lib/utils";
import { Suspense } from "react";
export default async function Layout({
@@ -17,12 +19,22 @@ export default async function Layout({
return (
<Suspense>
- <div className="flex min-h-screen flex-col gap-4">
- <main className="mx-auto flex w-full max-w-2xl flex-1 flex-col px-3 py-2">
+ <EmbedShell
+ className={cn(
+ "flex min-h-screen flex-col gap-4",
+ "group-data-[embed=true]/embed:min-h-0",
+ )}
+ >
+ <main
+ className={cn(
+ "mx-auto flex w-full max-w-2xl flex-1 flex-col px-3 py-2",
+ "group-data-[embed=true]/embed:mx-0 group-data-[embed=true]/embed:max-w-none",
+ )}
+ >
{children}
</main>
<Footer className="w-full border-t" />
- </div>
+ </EmbedShell>
</Suspense>
);
}
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx
new file mode 100644
index 000000000..8c77c2cb9
--- /dev/null
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/client.tsx
@@ -0,0 +1,351 @@
+"use client";
+
+import { Link } from "@/components/common/link";
+import { useStatusPage } from "@/components/status-page/floating-button";
+import {
+ Status,
+ StatusContent,
+ StatusDescription,
+ StatusHeader,
+ StatusTitle,
+} from "@/components/status-page/status";
+import {
+ StatusBanner,
+ StatusBannerContainer,
+ StatusBannerContent,
+ StatusBannerTabs,
+ StatusBannerTabsContent,
+ StatusBannerTabsList,
+ StatusBannerTabsTrigger,
+} from "@/components/status-page/status-banner";
+import {
+ StatusEventAffected,
+ StatusEventAffectedBadge,
+ StatusEventTimelineMaintenance,
+ StatusEventTimelineReportUpdate,
+} from "@/components/status-page/status-events";
+import { StatusFeed } from "@/components/status-page/status-feed";
+import { StatusMonitor } from "@/components/status-page/status-monitor";
+import { StatusTrackerGroup } from "@/components/status-page/status-tracker-group";
+import { useEmbed } from "@/hooks/use-embed";
+import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";
+import { useTRPC } from "@/lib/trpc/client";
+import { Separator } from "@openstatus/ui/components/ui/separator";
+import { cn } from "@openstatus/ui/lib/utils";
+import { skipToken, useQuery } from "@tanstack/react-query";
+import { notFound, useParams } from "next/navigation";
+import { useMemo } from "react";
+
+export function Client() {
+ const prefix = usePathnamePrefix();
+ const { domain } = useParams<{ domain: string }>();
+ const { cardType, barType, showUptime } = useStatusPage();
+ const embed = useEmbed();
+ const trpc = useTRPC();
+
+ // NOTE: we cannot use `cardType` and `barType` here because of queryKey changes
+ // It wouldn't match the server prefetch keys and we would have to refetch the page here
+ const {
+ data: pageInitial,
+ error,
+ isLoading: isPageLoading,
+ } = useQuery({
+ ...trpc.statusPage.get.queryOptions({
+ slug: domain,
+ }),
+ enabled: !!domain,
+ });
+
+ // Handle case where page doesn't exist or query fails
+ if (!isPageLoading && (error || !pageInitial)) {
+ notFound();
+ }
+
+ const componentsVisible =
+ !embed.mode || embed.sections.includes("components");
+
+ const hasCustomConfig = pageInitial?.configuration
+ ? pageInitial.configuration.type !== barType ||
+ pageInitial.configuration.value !== cardType
+ : false;
+
+ // NOTE: instead, we use the `enabled` flag to only fetch the page if the configuration differs.
+ // Also skip when `components` section is hidden in embed mode — this query only matters there.
+ const { data: pageWithCustomConfiguration } = useQuery({
+ ...trpc.statusPage.get.queryOptions({
+ slug: domain,
+ cardType,
+ barType,
+ }),
+ enabled: !!domain && hasCustomConfig && componentsVisible,
+ });
+
+ // NOTE: we can prefetch that to avoid loading state
+ // NOTE: using skipToken instead of enabled:false to prevent tRPC from including this in a batch request with undefined input
+ const { data: uptimeData, isLoading } = useQuery(
+ trpc.statusPage.getUptime.queryOptions(
+ componentsVisible && pageInitial && pageInitial.pageComponents.length > 0
+ ? {
+ slug: domain,
+ pageComponentIds: pageInitial.pageComponents.map((c) =>
+ c.id.toString(),
+ ),
+ cardType,
+ barType,
+ }
+ : skipToken,
+ ),
+ );
+
+ // NOTE: we need to filter out the incidents as we don't want to show all of them in the banner - a single one is enough
+ // REMINDER: we could move that to the server - but we might wanna have the info of all openEvents actually
+ const events = useMemo(() => {
+ let hasIncident = false;
+ return (
+ pageInitial?.openEvents.filter((e) => {
+ if (e.type !== "incident") return true;
+ if (hasIncident) return false;
+ hasIncident = true;
+ return true;
+ }) ?? []
+ );
+ }, [pageInitial]);
+
+ if (!pageInitial) return null;
+
+ // REMINDER: if we are using the custom configuration, we need to use the pageWithCustomConfiguration
+ const page = pageWithCustomConfiguration ?? pageInitial;
+
+ return (
+ <div className="flex flex-col gap-6">
+ <Status variant={page.status}>
+ <StatusHeader className="group-data-[hide-title=true]/embed:hidden">
+ <StatusTitle>{page.title}</StatusTitle>
+ <StatusDescription>{page.description}</StatusDescription>
+ </StatusHeader>
+ {events.length > 0 ? (
+ <StatusContent className="group-data-[hide-banner=true]/embed:hidden">
+ <StatusBannerTabs
+ defaultValue={`${events[0].type}-${events[0].id}`}
+ >
+ <StatusBannerTabsList>
+ {events.map((e, i) => {
+ return (
+ <StatusBannerTabsTrigger
+ value={`${e.type}-${e.id}`}
+ status={e.status}
+ key={`${e.type}-${e.id}`}
+ className={cn(
+ i === 0 && "rounded-tl-lg",
+ i === events.length - 1 && "rounded-tr-lg",
+ )}
+ >
+ {e.name}
+ </StatusBannerTabsTrigger>
+ );
+ })}
+ </StatusBannerTabsList>
+ {events.map((e) => {
+ if (e.type === "report") {
+ const report = page.statusReports.find(
+ (report) => report.id === e.id,
+ );
+ if (!report) return null;
+ const lastUpdate = report.statusReportUpdates.sort(
+ (a, b) => b.date.getTime() - a.date.getTime(),
+ )[0];
+ if (!lastUpdate) return null;
+ return (
+ <StatusBannerTabsContent
+ value={`${e.type}-${e.id}`}
+ key={`${e.type}-${e.id}`}
+ >
+ <Link
+ variant="unstyled"
+ href={`${prefix ? `/${prefix}` : ""}/events/report/${report.id}`}
+ className="rounded-lg"
+ >
+ <StatusBannerContainer status={e.status}>
+ <StatusBannerContent>
+ <StatusEventTimelineReportUpdate
+ report={lastUpdate}
+ withDot={false}
+ isLast={true}
+ withSeparator={false}
+ />
+ {report.statusReportsToPageComponents.length > 0 ? (
+ <StatusEventAffected>
+ {report.statusReportsToPageComponents.map(
+ (affected) => (
+ <StatusEventAffectedBadge
+ key={affected.pageComponent.id}
+ >
+ {affected.pageComponent.name}
+ </StatusEventAffectedBadge>
+ ),
+ )}
+ </StatusEventAffected>
+ ) : null}
+ </StatusBannerContent>
+ </StatusBannerContainer>
+ </Link>
+ </StatusBannerTabsContent>
+ );
+ }
+ if (e.type === "maintenance") {
+ const maintenance = page.maintenances.find(
+ (maintenance) => maintenance.id === e.id,
+ );
+ if (!maintenance) return null;
+ return (
+ <StatusBannerTabsContent
+ value={`${e.type}-${e.id}`}
+ key={e.id}
+ >
+ <Link
+ variant="unstyled"
+ href={`${prefix ? `/${prefix}` : ""}/events/maintenance/${maintenance.id}`}
+ className="rounded-lg"
+ >
+ <StatusBannerContainer status={e.status}>
+ <StatusBannerContent>
+ <StatusEventTimelineMaintenance
+ maintenance={maintenance}
+ withDot={false}
+ />
+ {maintenance.maintenancesToPageComponents.length >
+ 0 ? (
+ <StatusEventAffected>
+ {maintenance.maintenancesToPageComponents.map(
+ (affected) => (
+ <StatusEventAffectedBadge
+ key={affected.pageComponent.id}
+ >
+ {affected.pageComponent.name}
+ </StatusEventAffectedBadge>
+ ),
+ )}
+ </StatusEventAffected>
+ ) : null}
+ </StatusBannerContent>
+ </StatusBannerContainer>
+ </Link>
+ </StatusBannerTabsContent>
+ );
+ }
+ if (e.type === "incident") {
+ return (
+ <StatusBannerTabsContent
+ value={`${e.type}-${e.id}`}
+ key={e.id}
+ >
+ <StatusBanner status={e.status} />
+ </StatusBannerTabsContent>
+ );
+ }
+ return null;
+ })}
+ </StatusBannerTabs>
+ </StatusContent>
+ ) : (
+ <StatusBanner
+ status={page.status}
+ className="group-data-[hide-banner=true]/embed:hidden"
+ />
+ )}
+ {/* NOTE: check what gap feels right */}
+ {page.trackers.length > 0 ? (
+ <StatusContent className="gap-5 group-data-[hide-components=true]/embed:hidden">
+ {page.trackers.map((tracker) => {
+ if (tracker.type === "component") {
+ const component = tracker.component;
+
+ // Fetch uptime data by component ID
+ const { data, uptime } =
+ uptimeData?.find((u) => u.pageComponentId === component.id) ??
+ {};
+
+ return (
+ <StatusMonitor
+ key={`component-${component.id}`}
+ status={component.status}
+ data={data}
+ monitor={{
+ name: component.name,
+ description: component.description,
+ }}
+ uptime={uptime}
+ showUptime={showUptime}
+ isLoading={isLoading}
+ />
+ );
+ }
+
+ return (
+ <StatusTrackerGroup
+ key={`group-${tracker.groupId}`}
+ title={tracker.groupName}
+ status={tracker.status}
+ defaultOpen={tracker.defaultOpen}
+ >
+ {tracker.components.map((component) => {
+ const { data, uptime } =
+ uptimeData?.find(
+ (u) => u.pageComponentId === component.id,
+ ) ?? {};
+
+ return (
+ <StatusMonitor
+ key={`component-${component.id}`}
+ status={component.status}
+ data={data}
+ monitor={{
+ name: component.name,
+ description: component.description,
+ }}
+ uptime={uptime}
+ showUptime={showUptime}
+ isLoading={isLoading}
+ />
+ );
+ })}
+ </StatusTrackerGroup>
+ );
+ })}
+ </StatusContent>
+ ) : null}
+ <Separator className="group-data-[hide-components=true]/embed:hidden group-data-[hide-feed=true]/embed:hidden" />
+ <StatusContent className="group-data-[hide-feed=true]/embed:hidden">
+ <StatusFeed
+ statusReports={page.statusReports
+ .filter((report) =>
+ page.lastEvents.some(
+ (event) => event.id === report.id && event.type === "report",
+ ),
+ )
+ .map((report) => ({
+ ...report,
+ affected: report.statusReportsToPageComponents.map(
+ (component) => component.pageComponent.name,
+ ),
+ updates: report.statusReportUpdates,
+ }))}
+ maintenances={page.maintenances
+ .filter((maintenance) =>
+ page.lastEvents.some(
+ (event) =>
+ event.id === maintenance.id && event.type === "maintenance",
+ ),
+ )
+ .map((maintenance) => ({
+ ...maintenance,
+ affected: maintenance.maintenancesToPageComponents.map(
+ (component) => component.pageComponent.name,
+ ),
+ }))}
+ />
+ </StatusContent>
+ </Status>
+ </div>
+ );
+}
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/layout.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/layout.tsx
index 02625b897..d86bd2c11 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/layout.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/layout.tsx
@@ -1,17 +1,29 @@
+import { EmbedShell } from "@/components/layout/embed-shell";
import { Footer } from "@/components/nav/footer";
import { Header } from "@/components/nav/header";
+import { cn } from "@openstatus/ui/lib/utils";
import { Suspense } from "react";
export default function Layout({ children }: { children: React.ReactNode }) {
return (
<Suspense>
- <div className="flex min-h-screen flex-col gap-4">
+ <EmbedShell
+ className={cn(
+ "flex min-h-screen flex-col gap-4",
+ "group-data-[embed=true]/embed:min-h-0",
+ )}
+ >
<Header className="w-full border-b" />
- <main className="mx-auto flex w-full max-w-2xl flex-1 flex-col px-3 py-2">
+ <main
+ className={cn(
+ "mx-auto flex w-full max-w-2xl flex-1 flex-col px-3 py-2",
+ "group-data-[embed=true]/embed:mx-0 group-data-[embed=true]/embed:max-w-none",
+ )}
+ >
{children}
</main>
<Footer className="w-full border-t" />
- </div>
+ </EmbedShell>
</Suspense>
);
}
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/page.tsx b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/page.tsx
index 553129137..a66ffd221 100644
--- a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/page.tsx
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/page.tsx
@@ -1,336 +1,25 @@
-"use client";
-
-import { useStatusPage } from "@/components/status-page/floating-button";
-import {
- Status,
- StatusContent,
- StatusDescription,
- StatusHeader,
- StatusTitle,
-} from "@/components/status-page/status";
-import {
- StatusBanner,
- StatusBannerContainer,
- StatusBannerContent,
- StatusBannerTabs,
- StatusBannerTabsContent,
- StatusBannerTabsList,
- StatusBannerTabsTrigger,
-} from "@/components/status-page/status-banner";
-import {
- StatusEventAffected,
- StatusEventAffectedBadge,
- StatusEventTimelineMaintenance,
- StatusEventTimelineReportUpdate,
-} from "@/components/status-page/status-events";
-import { StatusFeed } from "@/components/status-page/status-feed";
-import { StatusMonitor } from "@/components/status-page/status-monitor";
-import { StatusTrackerGroup } from "@/components/status-page/status-tracker-group";
-import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";
-import { useTRPC } from "@/lib/trpc/client";
-import { Separator } from "@openstatus/ui/components/ui/separator";
-import { cn } from "@openstatus/ui/lib/utils";
-import { skipToken, useQuery } from "@tanstack/react-query";
-import Link from "next/link";
-import { notFound, useParams } from "next/navigation";
-import { useMemo } from "react";
-
-export default function Page() {
- const prefix = usePathnamePrefix();
- const { domain } = useParams<{ domain: string }>();
- const { cardType, barType, showUptime } = useStatusPage();
- const trpc = useTRPC();
-
- // NOTE: we cannot use `cardType` and `barType` here because of queryKey changes
- // It wouldn't match the server prefetch keys and we would have to refetch the page here
- const { data: pageInitial, error } = useQuery({
- ...trpc.statusPage.get.queryOptions({
- slug: domain,
- }),
- enabled: !!domain,
- });
-
- // Handle case where page doesn't exist or query fails
- if (error || (!pageInitial && domain)) {
- notFound();
+import type { Metadata } from "next";
+import type { SearchParams } from "nuqs/server";
+import { Client } from "./client";
+import { embedSearchParamsCache } from "./search-params";
+
+export async function generateMetadata({
+ searchParams,
+}: {
+ searchParams: Promise<SearchParams>;
+}): Promise<Metadata> {
+ const { embed } = await embedSearchParamsCache.parse(searchParams);
+ if (embed.mode) {
+ return { robots: { index: false, follow: false } };
}
+ return {};
+}
- const hasCustomConfig = pageInitial?.configuration
- ? pageInitial.configuration.type !== barType ||
- pageInitial.configuration.value !== cardType
- : false;
-
- // NOTE: instead, we use the `enabled` flag to only fetch the page if the configuration differs
- const { data: pageWithCustomConfiguration } = useQuery({
- ...trpc.statusPage.get.queryOptions({
- slug: domain,
- cardType,
- barType,
- }),
- enabled: !!domain && hasCustomConfig,
- });
-
- // NOTE: we can prefetch that to avoid loading state
- // NOTE: using skipToken instead of enabled:false to prevent tRPC from including this in a batch request with undefined input
- const { data: uptimeData, isLoading } = useQuery(
- trpc.statusPage.getUptime.queryOptions(
- pageInitial && pageInitial.pageComponents.length > 0
- ? {
- slug: domain,
- pageComponentIds: pageInitial.pageComponents.map((c) =>
- c.id.toString(),
- ),
- cardType,
- barType,
- }
- : skipToken,
- ),
- );
-
- // NOTE: we need to filter out the incidents as we don't want to show all of them in the banner - a single one is enough
- // REMINDER: we could move that to the server - but we might wanna have the info of all openEvents actually
- const events = useMemo(() => {
- let hasIncident = false;
- return (
- pageInitial?.openEvents.filter((e) => {
- if (e.type !== "incident") return true;
- if (hasIncident) return false;
- hasIncident = true;
- return true;
- }) ?? []
- );
- }, [pageInitial]);
-
- if (!pageInitial) return null;
-
- // REMINDER: if we are using the custom configuration, we need to use the pageWithCustomConfiguration
- const page = pageWithCustomConfiguration ?? pageInitial;
-
- return (
- <div className="flex flex-col gap-6">
- <Status variant={page.status}>
- <StatusHeader>
- <StatusTitle>{page.title}</StatusTitle>
- <StatusDescription>{page.description}</StatusDescription>
- </StatusHeader>
- {events.length > 0 ? (
- <StatusContent>
- <StatusBannerTabs
- defaultValue={`${events[0].type}-${events[0].id}`}
- >
- <StatusBannerTabsList>
- {events.map((e, i) => {
- return (
- <StatusBannerTabsTrigger
- value={`${e.type}-${e.id}`}
- status={e.status}
- key={`${e.type}-${e.id}`}
- className={cn(
- i === 0 && "rounded-tl-lg",
- i === events.length - 1 && "rounded-tr-lg",
- )}
- >
- {e.name}
- </StatusBannerTabsTrigger>
- );
- })}
- </StatusBannerTabsList>
- {events.map((e) => {
- if (e.type === "report") {
- const report = page.statusReports.find(
- (report) => report.id === e.id,
- );
- if (!report) return null;
- const lastUpdate = report.statusReportUpdates.sort(
- (a, b) => b.date.getTime() - a.date.getTime(),
- )[0];
- if (!lastUpdate) return null;
- return (
- <StatusBannerTabsContent
- value={`${e.type}-${e.id}`}
- key={`${e.type}-${e.id}`}
- >
- <Link
- href={`${prefix ? `/${prefix}` : ""}/events/report/${report.id}`}
- className="rounded-lg"
- >
- <StatusBannerContainer status={e.status}>
- <StatusBannerContent>
- <StatusEventTimelineReportUpdate
- report={lastUpdate}
- withDot={false}
- isLast={true}
- withSeparator={false}
- />
- {report.statusReportsToPageComponents.length > 0 ? (
- <StatusEventAffected>
- {report.statusReportsToPageComponents.map(
- (affected) => (
- <StatusEventAffectedBadge
- key={affected.pageComponent.id}
- >
- {affected.pageComponent.name}
- </StatusEventAffectedBadge>
- ),
- )}
- </StatusEventAffected>
- ) : null}
- </StatusBannerContent>
- </StatusBannerContainer>
- </Link>
- </StatusBannerTabsContent>
- );
- }
- if (e.type === "maintenance") {
- const maintenance = page.maintenances.find(
- (maintenance) => maintenance.id === e.id,
- );
- if (!maintenance) return null;
- return (
- <StatusBannerTabsContent
- value={`${e.type}-${e.id}`}
- key={e.id}
- >
- <Link
- href={`${prefix ? `/${prefix}` : ""}/events/maintenance/${maintenance.id}`}
- className="rounded-lg"
- >
- <StatusBannerContainer status={e.status}>
- <StatusBannerContent>
- <StatusEventTimelineMaintenance
- maintenance={maintenance}
- withDot={false}
- />
- {maintenance.maintenancesToPageComponents.length >
- 0 ? (
- <StatusEventAffected>
- {maintenance.maintenancesToPageComponents.map(
- (affected) => (
- <StatusEventAffectedBadge
- key={affected.pageComponent.id}
- >
- {affected.pageComponent.name}
- </StatusEventAffectedBadge>
- ),
- )}
- </StatusEventAffected>
- ) : null}
- </StatusBannerContent>
- </StatusBannerContainer>
- </Link>
- </StatusBannerTabsContent>
- );
- }
- if (e.type === "incident") {
- return (
- <StatusBannerTabsContent
- value={`${e.type}-${e.id}`}
- key={e.id}
- >
- <StatusBanner status={e.status} />
- </StatusBannerTabsContent>
- );
- }
- return null;
- })}
- </StatusBannerTabs>
- </StatusContent>
- ) : (
- <StatusBanner status={page.status} />
- )}
- {/* NOTE: check what gap feels right */}
- {page.trackers.length > 0 ? (
- <StatusContent className="gap-5">
- {page.trackers.map((tracker) => {
- if (tracker.type === "component") {
- const component = tracker.component;
-
- // Fetch uptime data by component ID
- const { data, uptime } =
- uptimeData?.find((u) => u.pageComponentId === component.id) ??
- {};
-
- return (
- <StatusMonitor
- key={`component-${component.id}`}
- status={component.status}
- data={data}
- monitor={{
- name: component.name,
- description: component.description,
- }}
- uptime={uptime}
- showUptime={showUptime}
- isLoading={isLoading}
- />
- );
- }
-
- return (
- <StatusTrackerGroup
- key={`group-${tracker.groupId}`}
- title={tracker.groupName}
- status={tracker.status}
- defaultOpen={tracker.defaultOpen}
- >
- {tracker.components.map((component) => {
- const { data, uptime } =
- uptimeData?.find(
- (u) => u.pageComponentId === component.id,
- ) ?? {};
-
- return (
- <StatusMonitor
- key={`component-${component.id}`}
- status={component.status}
- data={data}
- monitor={{
- name: component.name,
- description: component.description,
- }}
- uptime={uptime}
- showUptime={showUptime}
- isLoading={isLoading}
- />
- );
- })}
- </StatusTrackerGroup>
- );
- })}
- </StatusContent>
- ) : null}
- <Separator />
- <StatusContent>
- <StatusFeed
- statusReports={page.statusReports
- .filter((report) =>
- page.lastEvents.some(
- (event) => event.id === report.id && event.type === "report",
- ),
- )
- .map((report) => ({
- ...report,
- affected: report.statusReportsToPageComponents.map(
- (component) => component.pageComponent.name,
- ),
- updates: report.statusReportUpdates,
- }))}
- maintenances={page.maintenances
- .filter((maintenance) =>
- page.lastEvents.some(
- (event) =>
- event.id === maintenance.id && event.type === "maintenance",
- ),
- )
- .map((maintenance) => ({
- ...maintenance,
- affected: maintenance.maintenancesToPageComponents.map(
- (component) => component.pageComponent.name,
- ),
- }))}
- />
- </StatusContent>
- </Status>
- </div>
- );
+// NOTE: if we ever add a server component that reads embed state without
+// receiving `searchParams` as a prop, populate the cache here:
+// await embedSearchParamsCache.parse(searchParams);
+// `generateMetadata` already parses per-request, so the client tree doesn't
+// need it for SSR correctness (nuqs reads the URL directly on both sides).
+export default function Page() {
+ return <Client />;
}
diff --git a/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/search-params.ts b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/search-params.ts
new file mode 100644
index 000000000..6a2ca8ab4
--- /dev/null
+++ b/apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/search-params.ts
@@ -0,0 +1,6 @@
+import { embedParser } from "@/lib/embed-params";
+import { createSearchParamsCache } from "nuqs/server";
+
+export const embedSearchParamsCache = createSearchParamsCache({
+ embed: embedParser,
+});
diff --git a/apps/status-page/src/app/not-found.tsx b/apps/status-page/src/app/not-found.tsx
index cae8991a4..b31807d8d 100644
--- a/apps/status-page/src/app/not-found.tsx
+++ b/apps/status-page/src/app/not-found.tsx
@@ -1,12 +1,21 @@
"use client";
-import Link from "next/link";
import { useRouter } from "next/navigation";
+import { Suspense } from "react";
+import { Link } from "@/components/common/link";
import { ThemeProvider } from "@/components/themes/theme-provider";
import { Button } from "@openstatus/ui/components/ui/button";
export default function NotFound() {
+ return (
+ <Suspense>
+ <NotFoundContent />
+ </Suspense>
+ );
+}
+
+function NotFoundContent() {
const router = useRouter();
return (
@@ -34,7 +43,9 @@ export default function NotFound() {
Go Back
</Button>
<Button size="lg" asChild>
- <Link href="/">Home</Link>
+ <Link variant="unstyled" href="/">
+ Home
+ </Link>
</Button>
</div>
</div>
diff --git a/apps/status-page/src/components/common/link.tsx b/apps/status-page/src/components/common/link.tsx
index 9957f5033..f7ca6ca62 100644
--- a/apps/status-page/src/components/common/link.tsx
+++ b/apps/status-page/src/components/common/link.tsx
@@ -1,15 +1,18 @@
+"use client";
+
+import { useEmbed } from "@/hooks/use-embed";
import { cn } from "@openstatus/ui/lib/utils";
import { type VariantProps, cva } from "class-variance-authority";
import NextLink from "next/link";
export const linkVariants = cva(
- // NOTE: use same ring styles as the button
"outline-none focus-visible:ring-ring/50 focus-visible:ring-[3px] rounded-sm",
{
variants: {
variant: {
default: "text-foreground font-medium",
container: "focus-visible:border-ring",
+ unstyled: "",
},
},
defaultVariants: {
@@ -22,10 +25,30 @@ export function Link({
children,
className,
variant,
+ target,
+ rel,
...props
}: React.ComponentProps<typeof NextLink> & VariantProps<typeof linkVariants>) {
+ const { mode } = useEmbed();
+ // NOTE: treat any non-internal href as external so we don't hijack protocol
+ // links (mailto/tel/sms), absolute URLs, or protocol-relative URLs with
+ // embed-mode target="_blank" overrides.
+ const href = typeof props.href === "string" ? props.href : null;
+ const isExternal =
+ href !== null &&
+ (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith("//"));
+ const isAnchor = href?.startsWith("#");
+ const shouldOpenNewTab = mode && !isExternal && !isAnchor;
+ const embedTarget = shouldOpenNewTab ? "_blank" : target;
+ const embedRel = shouldOpenNewTab ? rel ?? "noopener noreferrer" : rel;
+
return (
- <NextLink className={cn(linkVariants({ variant, className }))} {...props}>
+ <NextLink
+ className={cn(linkVariants({ variant, className }))}
+ target={embedTarget}
+ rel={embedRel}
+ {...props}
+ >
{children}
</NextLink>
);
diff --git a/apps/status-page/src/components/layout/embed-shell.tsx b/apps/status-page/src/components/layout/embed-shell.tsx
new file mode 100644
index 000000000..37ed3261c
--- /dev/null
+++ b/apps/status-page/src/components/layout/embed-shell.tsx
@@ -0,0 +1,30 @@
+"use client";
+
+import { ALL_EMBED_SECTIONS, useEmbed } from "@/hooks/use-embed";
+import { cn } from "@openstatus/ui/lib/utils";
+
+export function EmbedShell({
+ children,
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ const { mode, sections } = useEmbed();
+ const hideAttrs = ALL_EMBED_SECTIONS.reduce<Record<string, "true">>(
+ (acc, section) => {
+ if (!sections.includes(section)) acc[`data-hide-${section}`] = "true";
+ return acc;
+ },
+ {},
+ );
+
+ return (
+ <div
+ {...props}
+ data-embed={mode ? "true" : undefined}
+ className={cn("group/embed", className)}
+ {...hideAttrs}
+ >
+ {children}
+ </div>
+ );
+}
diff --git a/apps/status-page/src/components/nav/footer.tsx b/apps/status-page/src/components/nav/footer.tsx
index 370c4fc92..751b62fc0 100644
--- a/apps/status-page/src/components/nav/footer.tsx
+++ b/apps/status-page/src/components/nav/footer.tsx
@@ -4,15 +4,20 @@ import { Link } from "@/components/common/link";
import { TimestampHoverCard } from "@/components/content/timestamp-hover-card";
import { LocaleSwitcher } from "@/components/locale-switcher";
import { ThemeDropdown } from "@/components/themes/theme-dropdown";
+import { useEmbed } from "@/hooks/use-embed";
import { useTRPC } from "@/lib/trpc/client";
import { Skeleton } from "@openstatus/ui/components/ui/skeleton";
+import { cn } from "@openstatus/ui/lib/utils";
import { useQuery } from "@tanstack/react-query";
import { Clock } from "lucide-react";
import { useExtracted } from "next-intl";
import { useParams } from "next/navigation";
import { useEffect, useState } from "react";
-export function Footer(props: React.ComponentProps<"footer">) {
+export function Footer({
+ className,
+ ...props
+}: React.ComponentProps<"footer">) {
const t = useExtracted();
const { domain } = useParams<{ domain: string }>();
const [isMounted, setIsMounted] = useState(false);
@@ -20,6 +25,7 @@ export function Footer(props: React.ComponentProps<"footer">) {
const { data: page, dataUpdatedAt } = useQuery({
...trpc.statusPage.get.queryOptions({ slug: domain }),
});
+ const embed = useEmbed();
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
useEffect(() => {
@@ -28,9 +34,16 @@ export function Footer(props: React.ComponentProps<"footer">) {
if (!page) return null;
+ // Whitelabel pages: hide the footer entirely in embed mode.
+ // Non-whitelabel pages: keep the "powered by" attribution visible; right-side controls hidden via CSS.
+ if (embed.mode && page.whiteLabel) return null;
+
return (
- <footer {...props}>
- <div className="mx-auto flex max-w-2xl items-center justify-between gap-4 px-3 py-2">
+ <footer
+ className={cn("group-data-[embed=true]/embed:border-t-0", className)}
+ {...props}
+ >
+ <div className="mx-auto flex max-w-2xl items-center justify-between gap-4 px-3 py-2 group-data-[embed=true]/embed:justify-center">
<div>
{!page.whiteLabel ? (
<p className="font-mono text-muted-foreground text-xs leading-none sm:text-sm">
@@ -45,7 +58,7 @@ export function Footer(props: React.ComponentProps<"footer">) {
</p>
) : null}
</div>
- <div className="flex items-center gap-2">
+ <div className="flex items-center gap-2 group-data-[embed=true]/embed:hidden">
<TimestampHoverCard
date={new Date(dataUpdatedAt)}
side="top"
diff --git a/apps/status-page/src/components/nav/header.tsx b/apps/status-page/src/components/nav/header.tsx
index 2e40ed361..4cb05f20b 100644
--- a/apps/status-page/src/components/nav/header.tsx
+++ b/apps/status-page/src/components/nav/header.tsx
@@ -76,7 +76,10 @@ function getStatusUpdateTypes(page: Page): StatusUpdateType[] {
return ["email", "slack", "rss", "json"] as const;
}
-export function Header(props: React.ComponentProps<"header">) {
+export function Header({
+ className,
+ ...props
+}: React.ComponentProps<"header">) {
const t = useExtracted();
const trpc = useTRPC();
const { domain } = useParams<{ domain: string }>();
@@ -110,7 +113,10 @@ export function Header(props: React.ComponentProps<"header">) {
);
return (
- <header {...props}>
+ <header
+ className={cn("group-data-[embed=true]/embed:hidden", className)}
+ {...props}
+ >
<nav className="mx-auto flex max-w-2xl items-center justify-between gap-3 px-3 py-2">
{/* NOTE: same width as the `StatusUpdates` button */}
<div className="flex w-[150px] shrink-0">
diff --git a/apps/status-page/src/components/status-page/status-blank.tsx b/apps/status-page/src/components/status-page/status-blank.tsx
index 04bc59984..86d4834c3 100644
--- a/apps/status-page/src/components/status-page/status-blank.tsx
+++ b/apps/status-page/src/components/status-page/status-blank.tsx
@@ -1,9 +1,9 @@
"use client";
+import { Link } from "@/components/common/link";
import { Button } from "@openstatus/ui/components/ui/button";
import { cn } from "@openstatus/ui/lib/utils";
import { useExtracted } from "next-intl";
-import Link from "next/link";
export function StatusBlankContainer({
children,
@@ -64,7 +64,9 @@ export function StatusBlankLink({
asChild
{...props}
>
- <Link href={href}>{children}</Link>
+ <Link variant="unstyled" href={href}>
+ {children}
+ </Link>
</Button>
);
}
diff --git a/apps/status-page/src/components/status-page/status-feed.tsx b/apps/status-page/src/components/status-page/status-feed.tsx
index 06378c9e8..0893494e5 100644
--- a/apps/status-page/src/components/status-page/status-feed.tsx
+++ b/apps/status-page/src/components/status-page/status-feed.tsx
@@ -1,7 +1,7 @@
"use client";
+import { Link } from "@/components/common/link";
import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";
import { useExtracted } from "next-intl";
-import Link from "next/link";
import {
StatusBlankContainer,
StatusBlankContent,
@@ -116,6 +116,7 @@ export function StatusFeed({
<StatusEventDate date={event.startDate} />
</StatusEventAside>
<Link
+ variant="unstyled"
href={`${prefix ? `/${prefix}` : ""}/events/report/${
report.id
}`}
@@ -150,6 +151,7 @@ export function StatusFeed({
<StatusEventDate date={event.startDate} />
</StatusEventAside>
<Link
+ variant="unstyled"
href={`${prefix ? `/${prefix}` : ""}/events/maintenance/${
maintenance.id
}`}
diff --git a/apps/status-page/src/components/status-page/status-tracker.tsx b/apps/status-page/src/components/status-page/status-tracker.tsx
index c0662d757..4f4b2affb 100644
--- a/apps/status-page/src/components/status-page/status-tracker.tsx
+++ b/apps/status-page/src/components/status-page/status-tracker.tsx
@@ -1,6 +1,7 @@
"use client";
import { Kbd } from "@/components/common/kbd";
+import { Link } from "@/components/common/link";
import { usePathnamePrefix } from "@/hooks/use-pathname-prefix";
import { formatDateRange } from "@/lib/formatter";
import type { RouterOutputs } from "@openstatus/api";
@@ -15,7 +16,6 @@ import { useMediaQuery } from "@openstatus/ui/hooks/use-media-query";
import { cn } from "@openstatus/ui/lib/utils";
import { formatDistanceStrict } from "date-fns";
import { useExtracted, useLocale } from "next-intl";
-import Link from "next/link";
import { useEffect, useRef, useState } from "react";
import { chartConfig } from "./utils";
@@ -324,6 +324,7 @@ export function StatusTracker({ data }: { data: UptimeData }) {
) {
return (
<Link
+ variant="unstyled"
key={`${event.id}-${event.type}`}
href={`${prefix ? `/${prefix}` : ""}/events/${
event.type
diff --git a/apps/status-page/src/components/themes/theme-provider.tsx b/apps/status-page/src/components/themes/theme-provider.tsx
index 6459132f4..1f254d24c 100644
--- a/apps/status-page/src/components/themes/theme-provider.tsx
+++ b/apps/status-page/src/components/themes/theme-provider.tsx
@@ -1,11 +1,22 @@
"use client";
+import { useEmbed } from "@/hooks/use-embed";
+import { embedThemeParser } from "@/lib/embed-params";
import { ThemeProvider as NextThemesProvider } from "next-themes";
+import { useQueryState } from "nuqs";
import type * as React from "react";
export function ThemeProvider({
children,
...props
}: React.ComponentProps<typeof NextThemesProvider>) {
- return <NextThemesProvider {...props}>{children}</NextThemesProvider>;
+ const embed = useEmbed();
+ const [theme] = useQueryState("theme", embedThemeParser);
+ const forcedTheme = embed.mode && theme ? theme : undefined;
+
+ return (
+ <NextThemesProvider {...props} forcedTheme={forcedTheme}>
+ {children}
+ </NextThemesProvider>
+ );
}
diff --git a/apps/status-page/src/hooks/use-embed.ts b/apps/status-page/src/hooks/use-embed.ts
new file mode 100644
index 000000000..64b6e9cf6
--- /dev/null
+++ b/apps/status-page/src/hooks/use-embed.ts
@@ -0,0 +1,15 @@
+"use client";
+
+import { embedParser } from "@/lib/embed-params";
+import { useQueryState } from "nuqs";
+
+export {
+ ALL_EMBED_SECTIONS,
+ type EmbedSection,
+ type EmbedState,
+} from "@/lib/embed-params";
+
+export function useEmbed() {
+ const [state] = useQueryState("embed", embedParser);
+ return state;
+}
diff --git a/apps/status-page/src/lib/embed-params.ts b/apps/status-page/src/lib/embed-params.ts
new file mode 100644
index 000000000..fd9352465
--- /dev/null
+++ b/apps/status-page/src/lib/embed-params.ts
@@ -0,0 +1,56 @@
+import { createParser, parseAsStringLiteral } from "nuqs/server";
+
+export const ALL_EMBED_SECTIONS = [
+ "title",
+ "banner",
+ "components",
+ "feed",
+] as const;
+
+export type EmbedSection = (typeof ALL_EMBED_SECTIONS)[number];
+
+export type EmbedState = { mode: boolean; sections: EmbedSection[] };
+
+export const embedParser = createParser<EmbedState>({
+ parse(raw) {
+ if (raw === "") {
+ return { mode: true, sections: [...ALL_EMBED_SECTIONS] };
+ }
+ const sections = Array.from(
+ new Set(
+ raw
+ .split(",")
+ .map((s) => s.trim().toLowerCase())
+ .filter((s): s is EmbedSection =>
+ (ALL_EMBED_SECTIONS as readonly string[]).includes(s),
+ ),
+ ),
+ );
+ // If nothing valid was parsed (e.g. `?embed=,` or `?embed=unknown`),
+ // fall back to showing everything rather than a blank embed.
+ if (sections.length === 0) {
+ return { mode: true, sections: [...ALL_EMBED_SECTIONS] };
+ }
+ return { mode: true, sections };
+ },
+ // NOTE: no writer (setEmbed) exists today; the serializer is only reached
+ // if one is added later. Returning "" for `!state.mode` could leak `?embed=`
+ // into the URL when exiting embed mode from a narrowed section set —
+ // revisit this logic when a writer is added.
+ serialize(state) {
+ if (!state.mode) return "";
+ if (state.sections.length === ALL_EMBED_SECTIONS.length) return "";
+ return state.sections.join(",");
+ },
+ eq: (a, b) => {
+ if (a.mode !== b.mode || a.sections.length !== b.sections.length)
+ return false;
+ const bSet = new Set(b.sections);
+ return a.sections.every((s) => bSet.has(s));
+ },
+}).withDefault({ mode: false, sections: [...ALL_EMBED_SECTIONS] });
+
+export const embedThemeParser = parseAsStringLiteral([
+ "light",
+ "dark",
+] as const);