Skip to content

Open-source status page, incident response and uptime monitoring

chore: improve onboarding flow (#2128)

Maximilian Kaskec08fb65ea20a
diff --git a/apps/dashboard/package.json b/apps/dashboard/package.json
index 0e47d26fa..b796e6ba0 100644
--- a/apps/dashboard/package.json
+++ b/apps/dashboard/package.json
@@ -45,6 +45,7 @@
"@openstatus/notification-webhook": "workspace:*",
"@openstatus/react": "workspace:*",
"@openstatus/regions": "workspace:*",
+ "@openstatus/services": "workspace:*",
"@openstatus/subscriptions": "workspace:*",
"@openstatus/theme-store": "workspace:*",
"@openstatus/tinybird": "workspace:*",
diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx b/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx
deleted file mode 100644
index 02bff6e3d..000000000
--- a/apps/dashboard/src/app/(dashboard)/onboarding/client.tsx
+++ /dev/null
@@ -1,451 +0,0 @@
-"use client";
-
-import {
- ActionCard,
- ActionCardDescription,
- ActionCardGroup,
- ActionCardHeader,
- ActionCardTitle,
-} from "@/components/content/action-card";
-import {
- Section,
- SectionDescription,
- SectionGroup,
- SectionHeader,
- SectionTitle,
-} from "@/components/content/section";
-import {
- FormCard,
- FormCardContent,
- FormCardDescription,
- FormCardFooter,
- FormCardHeader,
- FormCardTitle,
-} from "@/components/forms/form-card";
-import { CreateMonitorForm } from "@/components/forms/onboarding/create-monitor";
-import { CreatePageForm } from "@/components/forms/onboarding/create-page";
-import { QuestionForm } from "@/components/forms/onboarding/question";
-import { extractDomain } from "@/lib/domains";
-import { useTRPC } from "@/lib/trpc/client";
-import { cn } from "@/lib/utils";
-import { Button } from "@openstatus/ui/components/ui/button";
-import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
-import { Activity, ArrowUpRight, Layers, PanelTop } from "lucide-react";
-import Link from "next/link";
-import { usePathname, useRouter } from "next/navigation";
-import { useQueryStates } from "nuqs";
-import { useEffect, useMemo } from "react";
-import type { Intent } from "./search-params";
-import { searchParamsParsers } from "./search-params";
-
-const intents: {
- id: Intent;
- title: string;
- description: string;
- icon: typeof Activity;
-}[] = [
- {
- id: "status-page",
- title: "Status Page",
- description:
- "Keep your users informed with a public status page showing your system health.",
- icon: PanelTop,
- },
- {
- id: "monitoring",
- title: "Monitoring",
- description:
- "Track uptime and performance of your websites and APIs from multiple locations.",
- icon: Activity,
- },
- {
- id: "both",
- title: "Status Page & Monitoring",
- description:
- "Monitor your services and share real-time status with your users.",
- icon: Layers,
- },
-];
-
-function getTotalSteps(intent: Intent | null): number {
- if (intent === "both") return 4;
- return 3;
-}
-
-function getCurrentStepNumber(
- step: string,
- intent: Intent | null,
-): number | null {
- if (step === "1") return 1;
- if (step === "2") return 2;
- if (step === "3" && intent === "both") return 3;
- if (step === "next") return null; // no counter on final page
- return null;
-}
-
-export function Client() {
- const [{ step, intent, callbackUrl }, setSearchParams] = useQueryStates(
- searchParamsParsers,
- { history: "push" },
- );
- const router = useRouter();
- const pathname = usePathname();
- const trpc = useTRPC();
- const queryClient = useQueryClient();
- const { data: workspace, refetch } = useQuery(
- trpc.workspace.get.queryOptions(),
- );
- const triggerCheckMutation = useMutation(
- trpc.checker.triggerChecker.mutationOptions({}),
- );
- const createMonitorMutation = useMutation(
- trpc.monitor.new.mutationOptions({
- onSuccess: async (data) => {
- if (intent === "both") {
- await setSearchParams({ step: "3" });
- } else {
- await setSearchParams({ step: "next" });
- }
- if (data.active) {
- triggerCheckMutation.mutate({ id: data.id });
- }
- refetch();
- queryClient.invalidateQueries({
- queryKey: trpc.monitor.list.queryKey(),
- });
- },
- }),
- );
- const createPageMutation = useMutation(trpc.page.create.mutationOptions({}));
- const updateComponentsMutation = useMutation(
- trpc.pageComponent.updateOrder.mutationOptions({}),
- );
- const createFeedbackMutation = useMutation(
- trpc.feedback.submit.mutationOptions({}),
- );
-
- const totalSteps = getTotalSteps(intent);
- const currentStepNumber = getCurrentStepNumber(step, intent);
-
- const nudgeCards = useMemo(() => {
- const cards = [
- {
- id: "upgrade",
- title: "Upgrade your plan",
- description:
- "Unlock more monitors, status pages, and advanced features.",
- href: "/settings/billing",
- },
- {
- id: "invite",
- title: "Invite your team",
- description:
- "Collaborate with your team by inviting them to your workspace.",
- href: "/settings/general",
- },
- ];
-
- if (intent === "monitoring") {
- cards.push({
- id: "status-page",
- title: "Create a status page",
- description:
- "Keep your users informed with a public page showing your system health.",
- href: "/status-pages",
- });
- }
-
- if (intent === "status-page") {
- cards.push({
- id: "monitor",
- title: "Create a monitor",
- description:
- "Start tracking uptime and performance of your websites and APIs.",
- href: "/monitors",
- });
- }
-
- cards.push({
- id: "notifier",
- title: "Create a notifier",
- description: "Get notified when your website or API is down.",
- href: "/notifications",
- });
-
- return cards;
- }, [intent]);
-
- useEffect(() => {
- if (!callbackUrl) return;
- try {
- const url = new URL(callbackUrl, window.location.origin);
- if (url.pathname === "/" || url.pathname === "") return;
- if (url.origin !== window.location.origin) return;
- if (url.protocol !== "http:" && url.protocol !== "https:") return;
- router.push(`${url.pathname}${url.search}${url.hash}`);
- } catch {
- // Malformed URLs are not safe to navigate to
- }
- }, [callbackUrl, router]);
-
- const showMonitorForm =
- (step === "2" && intent === "monitoring") ||
- (step === "2" && intent === "both");
-
- const showStatusPageForm =
- (step === "2" && intent === "status-page") ||
- (step === "3" && intent === "both");
-
- return (
- <SectionGroup>
- <Section>
- <SectionHeader>
- <SectionTitle>Getting Started</SectionTitle>
- <SectionDescription>
- Welcome to openstatus. Let&apos;s get you set up.
- </SectionDescription>
- </SectionHeader>
- </Section>
- {step === "1" && (
- <Section>
- <SectionHeader>
- <SectionDescription>What are you looking for?</SectionDescription>
- </SectionHeader>
- <ActionCardGroup className="grid-cols-1 sm:grid-cols-2">
- {intents.map((item) => {
- const Icon = item.icon;
- return (
- <button
- key={item.id}
- type="button"
- className={
- item.id === "both" ? "text-left sm:col-span-2" : "text-left"
- }
- onClick={async () => {
- setSearchParams({ step: "2", intent: item.id });
- await createFeedbackMutation.mutateAsync({
- source: "onboarding-intent",
- message: `I'm looking for ${item.title}`,
- path: pathname,
- });
- }}
- >
- <ActionCard className="h-full w-full cursor-pointer transition-colors hover:border-foreground/20">
- <ActionCardHeader>
- <ActionCardTitle className="flex items-center gap-2">
- <Icon className="size-4 shrink-0 text-muted-foreground" />
- {item.title}
- </ActionCardTitle>
- <ActionCardDescription>
- {item.description}
- </ActionCardDescription>
- </ActionCardHeader>
- </ActionCard>
- </button>
- );
- })}
- </ActionCardGroup>
- </Section>
- )}
- {showMonitorForm && (
- <Section>
- <SectionHeader className="h-8 flex-row items-center justify-between">
- <SectionDescription className="tabular-nums">
- Step{" "}
- <span className="font-medium text-foreground">
- {currentStepNumber}
- </span>{" "}
- of{" "}
- <span className="font-medium text-foreground">{totalSteps}</span>
- </SectionDescription>
- <Button
- variant="ghost"
- size="sm"
- className="text-muted-foreground"
- onClick={() =>
- setSearchParams({
- step: intent === "both" ? "3" : "next",
- })
- }
- >
- Skip
- </Button>
- </SectionHeader>
- <FormCard>
- <FormCardHeader>
- <FormCardTitle>Create a monitor</FormCardTitle>
- <FormCardDescription>
- Get uptime, response time and more for your website or API.
- </FormCardDescription>
- </FormCardHeader>
- <FormCardContent>
- <CreateMonitorForm
- id="create-monitor-form"
- onSubmit={async (values) => {
- await createMonitorMutation.mutateAsync({
- url: values.url,
- name: new URL(values.url).hostname,
- method: "GET",
- headers: [],
- assertions: [],
- jobType: "http",
- active: true,
- });
- }}
- />
- </FormCardContent>
- <FormCardFooter>
- <Button form="create-monitor-form">Submit</Button>
- </FormCardFooter>
- </FormCard>
- </Section>
- )}
- {showStatusPageForm && (
- <Section>
- <SectionHeader className="h-8 flex-row items-center justify-between">
- <SectionDescription className="tabular-nums">
- Step{" "}
- <span className="font-medium text-foreground">
- {currentStepNumber}
- </span>{" "}
- of{" "}
- <span className="font-medium text-foreground">{totalSteps}</span>
- </SectionDescription>
- <Button
- variant="ghost"
- size="sm"
- className="text-muted-foreground"
- onClick={() => setSearchParams({ step: "next" })}
- >
- Skip
- </Button>
- </SectionHeader>
- <FormCard>
- <FormCardHeader>
- <FormCardTitle>Create a status page</FormCardTitle>
- <FormCardDescription>
- Inform your users about the status of your services.
- </FormCardDescription>
- </FormCardHeader>
- <FormCardContent>
- <CreatePageForm
- id="create-page-form"
- showComponents={intent === "status-page"}
- defaultValues={{
- slug: extractDomain(createMonitorMutation.data?.url ?? ""),
- }}
- onSubmit={async (values) => {
- if (!workspace?.id) return;
-
- const newPage = await createPageMutation.mutateAsync({
- slug: values.slug,
- title: values.slug.replace(/-/g, " "),
- description: "",
- monitors: createMonitorMutation.data?.id
- ? [
- {
- monitorId: createMonitorMutation.data.id,
- order: 0,
- },
- ]
- : [],
- workspaceId: workspace.id,
- legacyPage: false,
- });
-
- // Create static components if any were added
- const staticComponents = values.components?.filter(
- (c) => c.name.trim() !== "",
- );
- if (staticComponents?.length && newPage?.id) {
- const monitorComponentOffset = createMonitorMutation.data
- ?.id
- ? 1
- : 0;
- await updateComponentsMutation.mutateAsync({
- pageId: newPage.id,
- components: staticComponents.map((c, index) => ({
- name: c.name,
- type: "static" as const,
- monitorId: null,
- order: index + monitorComponentOffset,
- })),
- groups: [],
- });
- }
-
- await setSearchParams({ step: "next" });
- refetch();
- queryClient.invalidateQueries({
- queryKey: trpc.page.list.queryKey(),
- });
- }}
- />
- </FormCardContent>
- <FormCardFooter>
- <Button form="create-page-form">Submit</Button>
- </FormCardFooter>
- </FormCard>
- </Section>
- )}
- {step === "next" && (
- <>
- <Section>
- <SectionHeader className="h-8 flex-row items-center justify-between">
- <SectionDescription>
- How did you hear about openstatus?
- </SectionDescription>
- </SectionHeader>
- <QuestionForm
- onSubmit={async (values) => {
- await createFeedbackMutation.mutateAsync({
- source: "onboarding-source",
- message: `Heard about us via ${values.source}${
- values.other ? `: ${values.other}` : ""
- }`,
- path: pathname,
- });
- }}
- />
- </Section>
- <Section>
- <SectionHeader>
- <SectionDescription className="tabular-nums">
- What&apos;s next?
- </SectionDescription>
- </SectionHeader>
- <ActionCardGroup className="sm:grid-cols-2">
- {nudgeCards.map((action) => {
- const isExternal = action.href.startsWith("http");
- const className =
- action.id === "upgrade" ? "bg-muted" : undefined;
- return (
- <Link
- key={action.id}
- href={action.href}
- target={isExternal ? "_blank" : undefined}
- rel={isExternal ? "noopener noreferrer" : undefined}
- >
- <ActionCard className={cn("h-full w-full", className)}>
- <ActionCardHeader>
- <ActionCardTitle className="flex items-center justify-between gap-2">
- {action.title}
- {isExternal && (
- <ArrowUpRight className="size-4 shrink-0 text-muted-foreground group-hover/action-card:text-foreground" />
- )}
- </ActionCardTitle>
- <ActionCardDescription>
- {action.description}
- </ActionCardDescription>
- </ActionCardHeader>
- </ActionCard>
- </Link>
- );
- })}
- </ActionCardGroup>
- </Section>
- </>
- )}
- </SectionGroup>
- );
-}
diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/layout.tsx b/apps/dashboard/src/app/(dashboard)/onboarding/layout.tsx
deleted file mode 100644
index 88e1c9e7b..000000000
--- a/apps/dashboard/src/app/(dashboard)/onboarding/layout.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import {
- AppHeader,
- AppHeaderActions,
- AppHeaderContent,
-} from "@/components/nav/app-header";
-import { AppSidebarTrigger } from "@/components/nav/app-sidebar";
-import { NavBreadcrumb } from "@/components/nav/nav-breadcrumb";
-import { NavActions } from "./nav-actions";
-
-export default function Layout({ children }: { children: React.ReactNode }) {
- return (
- <div>
- <AppHeader>
- <AppHeaderContent>
- <AppSidebarTrigger />
- <NavBreadcrumb items={[{ type: "page", label: "Onboarding" }]} />
- </AppHeaderContent>
- <AppHeaderActions>
- <NavActions />
- </AppHeaderActions>
- </AppHeader>
- <main className="w-full flex-1">{children}</main>
- </div>
- );
-}
diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/nav-actions.tsx b/apps/dashboard/src/app/(dashboard)/onboarding/nav-actions.tsx
deleted file mode 100644
index 768c5c97f..000000000
--- a/apps/dashboard/src/app/(dashboard)/onboarding/nav-actions.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-import { NavFeedback } from "@/components/nav/nav-feedback";
-
-export function NavActions() {
- return (
- <div className="flex items-center gap-2 text-sm">
- <NavFeedback />
- </div>
- );
-}
diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/page.tsx b/apps/dashboard/src/app/(dashboard)/onboarding/page.tsx
deleted file mode 100644
index 6f63a2e2d..000000000
--- a/apps/dashboard/src/app/(dashboard)/onboarding/page.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Client } from "./client";
-import { searchParamsCache } from "./search-params";
-
-import type { SearchParams } from "nuqs";
-
-export default async function Page({
- searchParams,
-}: {
- searchParams: Promise<SearchParams>;
-}) {
- await searchParamsCache.parse(searchParams);
-
- return <Client />;
-}
diff --git a/apps/dashboard/src/app/(dashboard)/onboarding/search-params.ts b/apps/dashboard/src/app/(dashboard)/onboarding/search-params.ts
deleted file mode 100644
index 292f40462..000000000
--- a/apps/dashboard/src/app/(dashboard)/onboarding/search-params.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import {
- createSearchParamsCache,
- parseAsString,
- parseAsStringLiteral,
-} from "nuqs/server";
-
-const STEPS = ["1", "2", "3", "next"] as const;
-const INTENTS = ["monitoring", "status-page", "both"] as const;
-
-export type Intent = (typeof INTENTS)[number];
-
-export const searchParamsParsers = {
- step: parseAsStringLiteral(STEPS).withDefault("1"),
- intent: parseAsStringLiteral(INTENTS),
- callbackUrl: parseAsString,
-};
-
-export const searchParamsCache = createSearchParamsCache(searchParamsParsers);
diff --git a/apps/dashboard/src/app/api/onboarding/checks/route.ts b/apps/dashboard/src/app/api/onboarding/checks/route.ts
new file mode 100644
index 000000000..e8b5b8fdf
--- /dev/null
+++ b/apps/dashboard/src/app/api/onboarding/checks/route.ts
@@ -0,0 +1,113 @@
+import { getServiceContextFromRequest } from "@/lib/edge-context";
+import { ServiceError, type ServiceErrorCode } from "@openstatus/services";
+import {
+ type CheckResult,
+ streamMonitorPreview,
+} from "@openstatus/services/monitor";
+import { iteratorToStream } from "@openstatus/utils";
+import { z } from "zod";
+
+export const runtime = "edge";
+
+const SERVICE_ERROR_STATUS: Record<ServiceErrorCode, number> = {
+ NOT_FOUND: 404,
+ FORBIDDEN: 403,
+ UNAUTHORIZED: 401,
+ CONFLICT: 409,
+ VALIDATION: 400,
+ LIMIT_EXCEEDED: 429,
+ PRECONDITION_FAILED: 412,
+ INTERNAL: 500,
+};
+
+const requestSchema = z.object({
+ monitorId: z.number(),
+});
+
+const encoder = new TextEncoder();
+
+export async function POST(req: Request) {
+ const ctx = await getServiceContextFromRequest(req);
+ if (!ctx) {
+ return new Response(JSON.stringify({ error: "Unauthorized" }), {
+ status: 401,
+ headers: { "Content-Type": "application/json" },
+ });
+ }
+
+ let body: { monitorId: number };
+ try {
+ const json = await req.json();
+ const parsed = requestSchema.safeParse(json);
+ if (!parsed.success) {
+ return new Response(JSON.stringify({ error: "Invalid request" }), {
+ status: 400,
+ headers: { "Content-Type": "application/json" },
+ });
+ }
+ body = parsed.data;
+ } catch {
+ return new Response(JSON.stringify({ error: "Invalid JSON" }), {
+ status: 400,
+ headers: { "Content-Type": "application/json" },
+ });
+ }
+
+ // Resolve the monitor up-front so workspace-mismatch returns 404 instead of
+ // a 200 stream that fails on first iteration. We "prime" the generator by
+ // calling .next() once — if the workspace-scope check throws, we catch it
+ // synchronously here. Subsequent values come from the same generator.
+ const generator = streamMonitorPreview({
+ ctx,
+ input: { monitorId: body.monitorId },
+ });
+
+ let primed: IteratorResult<CheckResult>;
+ try {
+ primed = await generator.next();
+ } catch (err: unknown) {
+ if (err instanceof ServiceError) {
+ const status = SERVICE_ERROR_STATUS[err.code] ?? 500;
+ // Don't leak `INTERNAL` messages — they may include env-var names or
+ // stack details. Other codes are already user-facing strings.
+ const message =
+ err.code === "INTERNAL" ? "Internal server error" : err.message;
+ return new Response(JSON.stringify({ error: message }), {
+ status,
+ headers: { "Content-Type": "application/json" },
+ });
+ }
+ return new Response(JSON.stringify({ error: "Internal server error" }), {
+ status: 500,
+ headers: { "Content-Type": "application/json" },
+ });
+ }
+
+ const wrapped = (async function* () {
+ if (!primed.done && primed.value) {
+ yield encoder.encode(`${JSON.stringify(primed.value)}\n`);
+ }
+ try {
+ for await (const result of generator) {
+ yield encoder.encode(`${JSON.stringify(result)}\n`);
+ }
+ } catch (err) {
+ // The fan-out is `Promise.race`-based and individual region failures
+ // are returned as error-shaped CheckResults, so we don't expect to
+ // land here. Log so an unexpected failure isn't silent — the stream
+ // still closes cleanly so the client doesn't hang.
+ console.warn(
+ "[onboarding/checks] unexpected generator error post-prime",
+ err,
+ );
+ }
+ })();
+
+ const stream = iteratorToStream(wrapped);
+ return new Response(stream, {
+ headers: {
+ "Content-Type": "application/x-ndjson",
+ "Cache-Control": "no-store",
+ },
+ });
+}
diff --git a/apps/dashboard/src/app/globals.css b/apps/dashboard/src/app/globals.css
index f066a81dc..a175fd6ce 100644
--- a/apps/dashboard/src/app/globals.css
+++ b/apps/dashboard/src/app/globals.css
@@ -25,4 +25,24 @@
body {
@apply bg-background text-foreground;
}
+}
+
+@layer utilities {
+ /* Scoped to the onboarding status-page preview so `rounded-full` collapses
+ * to 0 when the active theme sets `--radius: 0` (every theme except the
+ * Rounded one). Mirrors the global override in
+ * `apps/status-page/src/app/globals.css` so the preview matches the real
+ * page's rendering. The `* 99999999` dance avoids `infinity * 1px` issues
+ * when `--radius` is 0. */
+ [data-status-preview] .rounded-full {
+ border-radius: calc(var(--radius) * 99999999);
+ }
+ [data-status-preview] .rounded-b-full {
+ border-bottom-left-radius: calc(var(--radius) * 99999999);
+ border-bottom-right-radius: calc(var(--radius) * 99999999);
+ }
+ [data-status-preview] .rounded-t-full {
+ border-top-left-radius: calc(var(--radius) * 99999999);
+ border-top-right-radius: calc(var(--radius) * 99999999);
+ }
}
\ No newline at end of file
diff --git a/apps/dashboard/src/app/login/page.tsx b/apps/dashboard/src/app/login/page.tsx
index 878622dc5..3bc658e89 100644
--- a/apps/dashboard/src/app/login/page.tsx
+++ b/apps/dashboard/src/app/login/page.tsx
@@ -30,10 +30,10 @@ export default async function Page(props: {
const { redirectTo } = searchParamsCache.parse(searchParams);
return (
- <div className="my-4 grid w-full max-w-lg gap-6">
+ <div className="my-16 grid w-full max-w-lg gap-6">
<div className="flex flex-col gap-1 text-center">
- <h1 className="font-semibold text-3xl tracking-tight">Sign In</h1>
- <p className="text-muted-foreground text-sm">
+ <h1 className="font-cal text-3xl tracking-tight">Sign In</h1>
+ <p className="text-pretty font-commit-mono text-muted-foreground text-sm">
Get started now. No credit card required.
</p>
</div>
@@ -68,7 +68,7 @@ export default async function Page(props: {
</LoginButton>
</form>
</div>
- <p className="mx-auto max-w-md px-8 text-center text-muted-foreground text-sm">
+ <p className="mx-auto max-w-md text-pretty px-8 text-center text-muted-foreground text-xs">
By clicking continue, you agree to our{" "}
<Link
href="https://openstatus.dev/legal/terms"
diff --git a/apps/dashboard/src/app/onboarding/_steps/step-1.tsx b/apps/dashboard/src/app/onboarding/_steps/step-1.tsx
new file mode 100644
index 000000000..31fa21aeb
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/_steps/step-1.tsx
@@ -0,0 +1,177 @@
+"use client";
+
+import { CreateMonitorForm } from "@/components/forms/onboarding/create-monitor";
+import {
+ OnboardingActions,
+ OnboardingFormColumn,
+ OnboardingLockedSummary,
+ OnboardingPreviewPlaceholder,
+ OnboardingPreviewPlaceholderContent,
+ OnboardingPreviewPlaceholderOverlay,
+ OnboardingPreviewPlaceholderText,
+ OnboardingResultColumn,
+ OnboardingResultHeading,
+ type OnboardingStep,
+ OnboardingStepDescription,
+ OnboardingStepHeader,
+ OnboardingStepTitle,
+ OnboardingStepper,
+} from "@/components/layout/onboarding-layout";
+import {
+ type OnboardingChecksRow,
+ OnboardingChecksTable,
+} from "@/components/onboarding/checks-table";
+import { checkResultToResponseLog } from "@/components/onboarding/checks-table-adapter";
+import type { useStreamChecks } from "@/components/onboarding/use-stream-checks";
+import { exampleChecks } from "@/data/onboarding-checks";
+import { cn } from "@/lib/utils";
+import { AVAILABLE_REGIONS } from "@openstatus/regions";
+import { Button } from "@openstatus/ui/components/ui/button";
+import { ArrowRight } from "lucide-react";
+import { useMemo } from "react";
+import type { OnboardingMonitor } from "../client";
+
+const TOTAL_REGIONS = AVAILABLE_REGIONS.length;
+
+export function Step1({
+ stepperSteps,
+ monitorStatus,
+ defaultUrl,
+ isSubmitting,
+ monitorData,
+ checkResults,
+ isStreaming,
+ onSubmit,
+ onSkip,
+ onContinue,
+ onRetryChecks,
+}: {
+ stepperSteps: OnboardingStep[];
+ monitorStatus: "skipped" | "completed" | null;
+ defaultUrl: string | undefined;
+ isSubmitting: boolean;
+ monitorData: OnboardingMonitor | undefined;
+ checkResults: ReturnType<typeof useStreamChecks>["results"];
+ isStreaming: boolean;
+ onSubmit: (values: { url: string }) => Promise<void>;
+ onSkip: () => void;
+ onContinue: () => void;
+ onRetryChecks: () => void;
+}) {
+ const isLocked = monitorStatus === "completed" && !!monitorData;
+ // Drop error-state probes and zero-status successes — those rows are
+ // noise (timeouts, auth misses, regions our checker can't currently
+ // reach) and clutter the table without telling the user anything.
+ const successfulResults = useMemo(
+ () =>
+ checkResults.filter((r) => r.state === "success" && (r.status ?? 0) > 0),
+ [checkResults],
+ );
+ const checksRows: OnboardingChecksRow[] = useMemo(
+ () =>
+ successfulResults.map((r) =>
+ checkResultToResponseLog(
+ r,
+ monitorData?.id ?? 0,
+ monitorData?.url ?? "",
+ ),
+ ),
+ [successfulResults, monitorData?.id, monitorData?.url],
+ );
+ const allFailed =
+ !isStreaming && checkResults.length > 0 && successfulResults.length === 0;
+
+ return (
+ <>
+ <OnboardingFormColumn>
+ <OnboardingStepper steps={stepperSteps} />
+ <OnboardingStepHeader>
+ <OnboardingStepTitle>
+ Check your URL from {TOTAL_REGIONS} regions
+ </OnboardingStepTitle>
+ <OnboardingStepDescription>
+ Drop in your API or website. We&apos;ll run a real check from every
+ openstatus region — first results land in under a second.
+ </OnboardingStepDescription>
+ </OnboardingStepHeader>
+ {isLocked ? (
+ <OnboardingLockedSummary
+ value={monitorData?.url ?? ""}
+ href={monitorData?.url}
+ helper="Rename, retarget, or tune this monitor later from its settings page."
+ />
+ ) : (
+ <CreateMonitorForm
+ id="onboarding-monitor-form"
+ defaultValues={defaultUrl ? { url: defaultUrl } : undefined}
+ onSubmit={onSubmit}
+ />
+ )}
+ <OnboardingActions>
+ {isLocked ? (
+ <Button onClick={onContinue}>
+ Continue <ArrowRight className="size-3" />
+ </Button>
+ ) : (
+ <>
+ <Button
+ form="onboarding-monitor-form"
+ disabled={isSubmitting}
+ type="submit"
+ >
+ {isSubmitting ? "Running…" : "Run first check"}
+ </Button>
+ <Button variant="ghost" onClick={onSkip} type="button">
+ I don&apos;t have a URL
+ </Button>
+ </>
+ )}
+ </OnboardingActions>
+ </OnboardingFormColumn>
+ <OnboardingResultColumn>
+ <OnboardingResultHeading>Global Checks</OnboardingResultHeading>
+ {!isLocked ? (
+ <ChecksPreviewPlaceholder />
+ ) : (
+ <OnboardingChecksTable
+ rows={checksRows}
+ totalRegions={TOTAL_REGIONS}
+ isStreaming={isStreaming}
+ allFailed={allFailed}
+ url={monitorData?.url}
+ onRetry={onRetryChecks}
+ />
+ )}
+ </OnboardingResultColumn>
+ </>
+ );
+}
+
+function ChecksPreviewPlaceholder(
+ props: Omit<
+ React.ComponentProps<typeof OnboardingPreviewPlaceholder>,
+ "children"
+ >,
+) {
+ return (
+ <OnboardingPreviewPlaceholder
+ className={cn("flex flex-col", props.className)}
+ {...props}
+ >
+ <OnboardingPreviewPlaceholderContent className="flex-col md:flex-1 md:[&>div]:flex-1">
+ <OnboardingChecksTable
+ rows={exampleChecks}
+ totalRegions={exampleChecks.length}
+ isStreaming={false}
+ allFailed={false}
+ onRetry={() => {}}
+ />
+ </OnboardingPreviewPlaceholderContent>
+ <OnboardingPreviewPlaceholderOverlay>
+ <OnboardingPreviewPlaceholderText>
+ Hit run to watch results land here from every region as they finish.
+ </OnboardingPreviewPlaceholderText>
+ </OnboardingPreviewPlaceholderOverlay>
+ </OnboardingPreviewPlaceholder>
+ );
+}
diff --git a/apps/dashboard/src/app/onboarding/_steps/step-2.tsx b/apps/dashboard/src/app/onboarding/_steps/step-2.tsx
new file mode 100644
index 000000000..79250f6fa
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/_steps/step-2.tsx
@@ -0,0 +1,136 @@
+"use client";
+
+import {
+ CreatePageForm,
+ type FormValues as CreatePageFormValues,
+} from "@/components/forms/onboarding/create-page";
+import {
+ OnboardingActions,
+ OnboardingFormColumn,
+ OnboardingLockedSummary,
+ OnboardingResultColumn,
+ OnboardingResultHeading,
+ type OnboardingStep,
+ OnboardingStepDescription,
+ OnboardingStepHeader,
+ OnboardingStepTitle,
+ OnboardingStepper,
+} from "@/components/layout/onboarding-layout";
+import { OnboardingStatusPagePreview } from "@/components/onboarding/status-page-preview";
+import type { ThemeKey } from "@openstatus/theme-store";
+import { Button } from "@openstatus/ui/components/ui/button";
+import { ArrowRight } from "lucide-react";
+import { useState } from "react";
+import type { OnboardingPage } from "../client";
+
+export function Step2({
+ stepperSteps,
+ pageStatus,
+ createdPageData,
+ slugFallback,
+ monitorSkipped,
+ monitorName,
+ isSubmitting,
+ onSubmit,
+ onSkip,
+ onContinue,
+}: {
+ stepperSteps: OnboardingStep[];
+ pageStatus: "skipped" | "completed" | null;
+ createdPageData: OnboardingPage | undefined;
+ slugFallback: string;
+ monitorSkipped: boolean;
+ monitorName: string | null;
+ isSubmitting: boolean;
+ onSubmit: (values: CreatePageFormValues) => Promise<void>;
+ onSkip: () => void;
+ onContinue: () => void;
+}) {
+ const isLocked = pageStatus === "completed" && !!createdPageData;
+
+ // Live preview tracks the form values via `onValuesChange` below. Defaults
+ // mirror the form's initial state so the preview renders something on first
+ // paint before the user touches the inputs.
+ const [previewValues, setPreviewValues] = useState<CreatePageFormValues>({
+ slug: slugFallback,
+ theme: "default-rounded",
+ forceTheme: "system",
+ components: monitorSkipped ? [{ name: "Website" }] : undefined,
+ });
+ // Frozen at submit time so the locked preview shows what the user
+ // actually published, not whatever they last typed before clicking submit.
+ const [submittedValues, setSubmittedValues] =
+ useState<CreatePageFormValues | null>(null);
+ const lockedPreviewValues = submittedValues ?? previewValues;
+
+ return (
+ <>
+ <OnboardingFormColumn>
+ <OnboardingStepper steps={stepperSteps} />
+ <OnboardingStepHeader>
+ <OnboardingStepTitle>Publish a status page</OnboardingStepTitle>
+ <OnboardingStepDescription>
+ Pick a subdomain and a theme - your page goes live the moment you
+ publish. Configure everything else later from page settings.
+ </OnboardingStepDescription>
+ </OnboardingStepHeader>
+ {isLocked ? (
+ <OnboardingLockedSummary
+ value={`${createdPageData?.slug}.openstatus.dev`}
+ href={`https://${createdPageData?.slug}.openstatus.dev`}
+ helper="Theme, components, and visibility are editable later from page settings."
+ />
+ ) : (
+ <CreatePageForm
+ id="onboarding-page-form"
+ showComponents={monitorSkipped}
+ defaultValues={{ slug: slugFallback }}
+ onSubmit={async (values) => {
+ await onSubmit(values);
+ setSubmittedValues(values);
+ }}
+ onValuesChange={setPreviewValues}
+ />
+ )}
+ <OnboardingActions>
+ {isLocked ? (
+ <Button onClick={onContinue}>
+ Continue <ArrowRight className="size-3" />
+ </Button>
+ ) : (
+ <>
+ <Button
+ form="onboarding-page-form"
+ disabled={isSubmitting}
+ type="submit"
+ >
+ {isSubmitting ? "Publishing…" : "Publish my page"}
+ </Button>
+ <Button variant="ghost" onClick={onSkip} type="button">
+ Do this later
+ </Button>
+ </>
+ )}
+ </OnboardingActions>
+ </OnboardingFormColumn>
+ <OnboardingResultColumn>
+ <OnboardingResultHeading>Status Page Preview</OnboardingResultHeading>
+ <div className="flex h-[calc(100dvh-13rem)] flex-1 overflow-hidden md:h-auto md:min-h-0">
+ <OnboardingStatusPagePreview
+ slug={
+ isLocked ? createdPageData?.slug ?? "" : lockedPreviewValues.slug
+ }
+ title={(isLocked
+ ? createdPageData?.title ?? ""
+ : lockedPreviewValues.slug
+ ).replace(/-/g, " ")}
+ components={lockedPreviewValues.components ?? []}
+ monitorName={monitorName}
+ themeKey={lockedPreviewValues.theme as ThemeKey}
+ className="h-full w-full"
+ />
+ </div>
+ </OnboardingResultColumn>
+ </>
+ );
+}
diff --git a/apps/dashboard/src/app/onboarding/_steps/step-3.tsx b/apps/dashboard/src/app/onboarding/_steps/step-3.tsx
new file mode 100644
index 000000000..1611815f9
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/_steps/step-3.tsx
@@ -0,0 +1,126 @@
+"use client";
+
+import {
+ OnboardingActions,
+ OnboardingFormColumn,
+ OnboardingResultColumn,
+ type OnboardingStep,
+ OnboardingStepDescription,
+ OnboardingStepHeader,
+ OnboardingStepTitle,
+ OnboardingStepper,
+} from "@/components/layout/onboarding-layout";
+import {
+ FeatureBadgeWall,
+ QuestionPanel,
+} from "@/components/onboarding/feature-badges";
+import { Button } from "@openstatus/ui/components/ui/button";
+import {
+ Activity,
+ ArrowRight,
+ Bell,
+ Calendar,
+ CreditCard,
+ LayoutGrid,
+ PanelTop,
+ UserPlus,
+} from "lucide-react";
+import Link from "next/link";
+import { useMemo } from "react";
+
+export function Step3({
+ stepperSteps,
+ monitorStatus,
+ pageStatus,
+ onQuestionnaireSubmit,
+}: {
+ stepperSteps: OnboardingStep[];
+ monitorStatus: "skipped" | "completed" | null;
+ pageStatus: "skipped" | "completed" | null;
+ onQuestionnaireSubmit: (values: {
+ source: string;
+ other?: string;
+ }) => Promise<void>;
+}) {
+ const monitorSkipped = monitorStatus === "skipped";
+ const pageSkipped = pageStatus === "skipped";
+
+ const quickLinks = useMemo(() => {
+ type Link = {
+ name: string;
+ href: string;
+ icon: React.ComponentType<{ className?: string }>;
+ };
+
+ const priority: Link[] = [];
+ if (monitorSkipped) {
+ priority.push({ name: "Monitors", href: "/monitors", icon: Activity });
+ }
+ if (pageSkipped) {
+ priority.push({
+ name: "Status Pages",
+ href: "/status-pages",
+ icon: PanelTop,
+ });
+ }
+ const filler: Link[] = [
+ { name: "Invite team", href: "/settings/general", icon: UserPlus },
+ { name: "Notifiers", href: "/notifications", icon: Bell },
+ { name: "Overview", href: "/overview", icon: LayoutGrid },
+ { name: "Billing", href: "/settings/billing", icon: CreditCard },
+ ];
+ return [...priority, ...filler].slice(0, 4);
+ }, [monitorSkipped, pageSkipped]);
+
+ return (
+ <>
+ <OnboardingFormColumn>
+ <OnboardingStepper steps={stepperSteps} />
+ <OnboardingStepHeader>
+ <OnboardingStepTitle>You&apos;re live</OnboardingStepTitle>
+ <OnboardingStepDescription>
+ Jump into the product and explore what openstatus can do.
+ </OnboardingStepDescription>
+ </OnboardingStepHeader>
+ <div className="grid gap-2 sm:grid-cols-2">
+ {quickLinks.map((link) => (
+ <Link
+ key={link.name}
+ href={link.href}
+ className="flex items-center gap-2 rounded-md border border-border bg-background px-4 py-2 font-commit-mono text-muted-foreground text-sm transition-colors hover:bg-accent hover:text-accent-foreground"
+ >
+ <link.icon className="h-4 w-4" />
+ {link.name}
+ </Link>
+ ))}
+ </div>
+ <div className="flex flex-col gap-2">
+ <OnboardingActions className="flex-wrap">
+ <Button asChild>
+ <Link href="/overview">
+ Continue <ArrowRight className="size-3" />
+ </Link>
+ </Button>
+ <Button variant="ghost" asChild>
+ <a
+ href="https://cal.com/team/openstatus/15min"
+ target="_blank"
+ rel="noopener noreferrer"
+ >
+ <Calendar className="size-3" />
+ Talk to a founder
+ </a>
+ </Button>
+ </OnboardingActions>
+ <p className="text-muted-foreground text-xs">
+ SOC2 audit incoming? Ping us for a 14-day free trial.
+ </p>
+ </div>
+ </OnboardingFormColumn>
+ <OnboardingResultColumn>
+ <QuestionPanel onSubmit={onQuestionnaireSubmit} />
+ <FeatureBadgeWall />
+ </OnboardingResultColumn>
+ </>
+ );
+}
diff --git a/apps/dashboard/src/app/onboarding/client.tsx b/apps/dashboard/src/app/onboarding/client.tsx
new file mode 100644
index 000000000..e648ffac2
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/client.tsx
@@ -0,0 +1,291 @@
+"use client";
+
+import {
+ OnboardingLayout,
+ OnboardingShell,
+} from "@/components/layout/onboarding-layout";
+import { useStreamChecks } from "@/components/onboarding/use-stream-checks";
+import { getCompanyDomainFromEmail } from "@/lib/onboarding/email-domain";
+import { useTRPC } from "@/lib/trpc/client";
+import type { RouterOutputs } from "@openstatus/api";
+import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
+import { Activity, PanelTop, Rocket } from "lucide-react";
+import { usePathname } from "next/navigation";
+import { useQueryStates } from "nuqs";
+import { generateSlug } from "random-word-slugs";
+import { useEffect, useMemo, useRef } from "react";
+import { Step1 } from "./_steps/step-1";
+import { Step2 } from "./_steps/step-2";
+import { Step3 } from "./_steps/step-3";
+import { searchParamsParsers } from "./search-params";
+
+export type OnboardingMonitor = Pick<
+ RouterOutputs["monitor"]["list"][number],
+ "id" | "url"
+>;
+export type OnboardingPage = Pick<
+ RouterOutputs["page"]["list"][number],
+ "id" | "slug" | "title"
+>;
+
+const STEPS = [
+ { id: "1", label: "Monitor", icon: <Activity /> },
+ { id: "2", label: "Status page", icon: <PanelTop /> },
+ { id: "3", label: "Launch", icon: <Rocket /> },
+] as const;
+
+// Fallback URL used when the user's email domain is generic (gmail, yahoo, …).
+// Keeps the magic-moment frictionless: hit submit on an empty form and a real
+// probe runs against an openstatus-owned demo target.
+const DEMO_FALLBACK_URL = "https://openstat.us";
+
+// Convert a hostname to a slug that satisfies the page schema
+// (`[A-Za-z0-9-]`, min length 3). Caller must pass a hostname — strip URL
+// scheme/`www` upstream.
+//
+// Picks the registrable label (penultimate segment) when present so
+// `api.mycompany.com` → `mycompany` rather than the generic `api`.
+function slugifyHostname(hostname: string): string {
+ const labels = hostname
+ .toLowerCase()
+ .replace(/^www\./, "")
+ .split(".");
+ const base = labels.length > 1 ? labels[labels.length - 2] : labels[0];
+ return base
+ .replace(/[^a-z0-9-]/g, "-")
+ .replace(/-+/g, "-")
+ .replace(/^-|-$/g, "")
+ .slice(0, 32);
+}
+
+function safeHostname(url: string): string | null {
+ try {
+ return new URL(url).hostname;
+ } catch {
+ return null;
+ }
+}
+
+export function Client() {
+ const [{ step, monitor, page }, setSearchParams] = useQueryStates(
+ searchParamsParsers,
+ { history: "push" },
+ );
+ const pathname = usePathname();
+ const trpc = useTRPC();
+ const queryClient = useQueryClient();
+
+ const { data: workspace } = useQuery(trpc.workspace.get.queryOptions());
+ const { data: user } = useQuery(trpc.user.get.queryOptions());
+ // Ground truth for refresh + returning-user state.
+ const { data: monitors } = useQuery(trpc.monitor.list.queryOptions());
+ const { data: pages } = useQuery(trpc.page.list.queryOptions());
+
+ // Invalidate so workspace counts (sidebar quota, plan gates) stay fresh.
+ const createMonitorMutation = useMutation(
+ trpc.monitor.new.mutationOptions({
+ onSuccess: async () => {
+ await setSearchParams({ monitor: "completed" });
+ await Promise.all([
+ queryClient.invalidateQueries({
+ queryKey: trpc.workspace.get.queryKey(),
+ }),
+ queryClient.invalidateQueries({
+ queryKey: trpc.monitor.list.queryKey(),
+ }),
+ ]);
+ },
+ }),
+ );
+ const createPageMutation = useMutation(
+ trpc.page.create.mutationOptions({
+ onSuccess: async () => {
+ await setSearchParams({ page: "completed" });
+ await Promise.all([
+ queryClient.invalidateQueries({
+ queryKey: trpc.workspace.get.queryKey(),
+ }),
+ queryClient.invalidateQueries({
+ queryKey: trpc.page.list.queryKey(),
+ }),
+ ]);
+ },
+ }),
+ );
+ const updateComponentsMutation = useMutation(
+ trpc.pageComponent.updateOrder.mutationOptions({}),
+ );
+ const createFeedbackMutation = useMutation(
+ trpc.feedback.submit.mutationOptions({}),
+ );
+
+ const {
+ results: checkResults,
+ isStreaming,
+ start: startChecks,
+ stop: stopChecks,
+ } = useStreamChecks();
+ const checksStartedRef = useRef(false);
+
+ // Fresh mutation data wins; fall back to the most recent server row.
+ const monitorData: OnboardingMonitor | undefined =
+ createMonitorMutation.data ??
+ (monitors?.[0] ? { id: monitors[0].id, url: monitors[0].url } : undefined);
+ const pageData: OnboardingPage | undefined =
+ createPageMutation.data ??
+ (pages?.[0]
+ ? {
+ id: pages[0].id,
+ slug: pages[0].slug,
+ title: pages[0].title,
+ }
+ : undefined);
+
+ const companyDomain = useMemo(
+ () => getCompanyDomainFromEmail(user?.email),
+ [user?.email],
+ );
+
+ const defaultUrl = companyDomain
+ ? `https://${companyDomain}`
+ : DEMO_FALLBACK_URL;
+
+ const slugFallback = useMemo(() => {
+ const candidates: string[] = [];
+ if (monitorData?.url) {
+ try {
+ candidates.push(slugifyHostname(new URL(monitorData.url).hostname));
+ } catch {
+ // Malformed URL — fall through to other candidates.
+ }
+ }
+ if (companyDomain) candidates.push(slugifyHostname(companyDomain));
+ const valid = candidates.find((c) => c.length >= 3);
+ if (valid) return valid;
+ return generateSlug(2, { format: "kebab" });
+ }, [monitorData?.url, companyDomain]);
+
+ // Auto-fire on step-1 fresh-create + refresh-of-locked. Skip on stale
+ // hydration so returning users don't accidentally re-probe.
+ useEffect(() => {
+ if (!monitorData?.id || step !== "1" || monitor !== "completed") return;
+ if (checksStartedRef.current) return;
+ checksStartedRef.current = true;
+ startChecks(monitorData.id);
+ return () => {
+ stopChecks();
+ };
+ }, [monitorData?.id, step, monitor, startChecks, stopChecks]);
+
+ const currentStepIndex = STEPS.findIndex((s) => s.id === step);
+ const stepperSteps = STEPS.map((s, i) => ({
+ id: s.id,
+ label: s.label,
+ icon: s.icon,
+ status:
+ step === s.id
+ ? ("current" as const)
+ : currentStepIndex > i
+ ? ("completed" as const)
+ : ("upcoming" as const),
+ }));
+
+ return (
+ <OnboardingLayout>
+ <OnboardingShell>
+ {step === "1" ? (
+ <Step1
+ stepperSteps={stepperSteps}
+ monitorStatus={monitor}
+ defaultUrl={defaultUrl}
+ isSubmitting={createMonitorMutation.isPending}
+ monitorData={monitorData}
+ checkResults={checkResults}
+ isStreaming={isStreaming}
+ onSubmit={async (values) => {
+ await createMonitorMutation.mutateAsync({
+ url: values.url,
+ name: safeHostname(values.url) ?? values.url,
+ method: "GET",
+ headers: [],
+ assertions: [],
+ jobType: "http",
+ active: true,
+ });
+ }}
+ onSkip={() => setSearchParams({ monitor: "skipped", step: "2" })}
+ onContinue={() => {
+ setSearchParams({ step: "2" });
+ stopChecks();
+ }}
+ onRetryChecks={() => {
+ if (monitorData?.id) startChecks(monitorData.id);
+ }}
+ />
+ ) : null}
+ {step === "2" ? (
+ <Step2
+ stepperSteps={stepperSteps}
+ pageStatus={page}
+ createdPageData={pageData}
+ slugFallback={slugFallback}
+ monitorSkipped={monitor === "skipped"}
+ monitorName={
+ monitorData?.url ? safeHostname(monitorData.url) : null
+ }
+ isSubmitting={createPageMutation.isPending}
+ onSubmit={async (values) => {
+ if (!workspace?.id) return;
+ const newPage = await createPageMutation.mutateAsync({
+ slug: values.slug,
+ title: values.slug.replace(/-/g, " "),
+ description: "",
+ monitors: monitorData?.id
+ ? [{ monitorId: monitorData.id, order: 0 }]
+ : [],
+ workspaceId: workspace.id,
+ legacyPage: false,
+ forceTheme: values.forceTheme,
+ configuration: { theme: values.theme },
+ });
+ const staticComponents = values.components?.filter(
+ (c) => c.name.trim() !== "",
+ );
+ if (staticComponents?.length && newPage?.id) {
+ const offset = monitorData?.id ? 1 : 0;
+ await updateComponentsMutation.mutateAsync({
+ pageId: newPage.id,
+ components: staticComponents.map((c, index) => ({
+ name: c.name,
+ type: "static" as const,
+ monitorId: null,
+ order: index + offset,
+ })),
+ groups: [],
+ });
+ }
+ }}
+ onSkip={() => setSearchParams({ page: "skipped", step: "3" })}
+ onContinue={() => setSearchParams({ step: "3" })}
+ />
+ ) : null}
+ {step === "3" ? (
+ <Step3
+ stepperSteps={stepperSteps}
+ monitorStatus={monitor}
+ pageStatus={page}
+ onQuestionnaireSubmit={async (values) => {
+ await createFeedbackMutation.mutateAsync({
+ source: "onboarding-source",
+ message: `Heard about us via ${values.source}${
+ values.other ? `: ${values.other}` : ""
+ }`,
+ path: pathname,
+ });
+ }}
+ />
+ ) : null}
+ </OnboardingShell>
+ </OnboardingLayout>
+ );
+}
diff --git a/apps/dashboard/src/app/onboarding/layout.tsx b/apps/dashboard/src/app/onboarding/layout.tsx
new file mode 100644
index 000000000..4889c44ef
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/layout.tsx
@@ -0,0 +1,15 @@
+import { HydrateClient, getQueryClient, trpc } from "@/lib/trpc/server";
+
+export default async function Layout({
+ children,
+}: {
+ children: React.ReactNode;
+}) {
+ const queryClient = getQueryClient();
+ await queryClient.prefetchQuery(trpc.workspace.get.queryOptions());
+ await queryClient.prefetchQuery(trpc.user.get.queryOptions());
+ await queryClient.prefetchQuery(trpc.monitor.list.queryOptions());
+ await queryClient.prefetchQuery(trpc.page.list.queryOptions());
+
+ return <HydrateClient>{children}</HydrateClient>;
+}
diff --git a/apps/dashboard/src/app/onboarding/page.tsx b/apps/dashboard/src/app/onboarding/page.tsx
new file mode 100644
index 000000000..692eb93dd
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/page.tsx
@@ -0,0 +1,72 @@
+import { getQueryClient, trpc } from "@/lib/trpc/server";
+import { redirect } from "next/navigation";
+import type { SearchParams } from "nuqs";
+import { Client } from "./client";
+import { searchParamsCache } from "./search-params";
+
+export default async function Page({
+ searchParams,
+}: {
+ searchParams: Promise<SearchParams>;
+}) {
+ const params = await searchParamsCache.parse(searchParams);
+
+ // Same-origin-only redirect: strip host, reject non-HTTP and `//…`
+ // (protocol-relative). `/` and `/login` are app-specific UX skips.
+ if (params.callbackUrl) {
+ try {
+ const target = new URL(params.callbackUrl, "http://_");
+ const safe =
+ (target.protocol === "http:" || target.protocol === "https:") &&
+ target.pathname.startsWith("/") &&
+ !target.pathname.startsWith("//") &&
+ target.pathname !== "/" &&
+ target.pathname !== "/login";
+ if (safe) {
+ redirect(`${target.pathname}${target.search}${target.hash}`);
+ }
+ } catch {
+ // malformed — fall through
+ }
+ }
+
+ const queryClient = getQueryClient();
+ const [monitors, pages] = await Promise.all([
+ queryClient.fetchQuery(trpc.monitor.list.queryOptions()),
+ queryClient.fetchQuery(trpc.page.list.queryOptions()),
+ ]);
+
+ const updates: {
+ step?: "1" | "2" | "3";
+ monitor?: "completed";
+ page?: "completed";
+ } = {};
+
+ let monitorDone = params.monitor !== null;
+ let pageDone = params.page !== null;
+ if (!monitorDone && monitors.length > 0) {
+ updates.monitor = "completed";
+ monitorDone = true;
+ }
+ if (!pageDone && pages.length > 0) {
+ updates.page = "completed";
+ pageDone = true;
+ }
+
+ if (params.step === "1" && monitorDone && pageDone) updates.step = "3";
+ else if (params.step === "1" && monitorDone) updates.step = "2";
+ else if (params.step === "2" && pageDone) updates.step = "3";
+
+ if (Object.keys(updates).length > 0) {
+ const next = new URLSearchParams();
+ next.set("step", updates.step ?? params.step);
+ const monitor = updates.monitor ?? params.monitor;
+ if (monitor) next.set("monitor", monitor);
+ const page = updates.page ?? params.page;
+ if (page) next.set("page", page);
+ if (params.callbackUrl) next.set("callbackUrl", params.callbackUrl);
+ redirect(`/onboarding?${next.toString()}`);
+ }
+
+ return <Client />;
+}
diff --git a/apps/dashboard/src/app/onboarding/search-params.ts b/apps/dashboard/src/app/onboarding/search-params.ts
new file mode 100644
index 000000000..57641c903
--- /dev/null
+++ b/apps/dashboard/src/app/onboarding/search-params.ts
@@ -0,0 +1,21 @@
+import {
+ createSearchParamsCache,
+ parseAsString,
+ parseAsStringLiteral,
+} from "nuqs/server";
+
+const STEPS = ["1", "2", "3"] as const;
+const STEP_STATUSES = ["skipped", "completed"] as const;
+
+export type Step = (typeof STEPS)[number];
+export type StepStatus = (typeof STEP_STATUSES)[number];
+export type DerivedStepStatus = StepStatus | "untouched";
+
+export const searchParamsParsers = {
+ step: parseAsStringLiteral(STEPS).withDefault("1"),
+ monitor: parseAsStringLiteral(STEP_STATUSES),
+ page: parseAsStringLiteral(STEP_STATUSES),
+ callbackUrl: parseAsString,
+};
+
+export const searchParamsCache = createSearchParamsCache(searchParamsParsers);
diff --git a/apps/dashboard/src/components/data-table/response-logs/columns.tsx b/apps/dashboard/src/components/data-table/response-logs/columns.tsx
index f1951e2e1..3d1614e10 100644
--- a/apps/dashboard/src/components/data-table/response-logs/columns.tsx
+++ b/apps/dashboard/src/components/data-table/response-logs/columns.tsx
@@ -176,6 +176,8 @@ function HoverCardTiming({
timing: NonNullable<Extract<ResponseLog, { type: "http" }>["timing"]>;
latency: number;
}) {
+ const phasesTotal =
+ Object.values(timing).reduce((acc, v) => acc + v, 0) || latency;
return (
<HoverCard openDelay={50} closeDelay={50}>
<HoverCardTrigger
@@ -188,7 +190,7 @@ function HoverCardTiming({
key={key}
className={cn("h-4")}
style={{
- width: `${(value / latency) * 100}%`,
+ width: `${(value / phasesTotal) * 100}%`,
backgroundColor: `var(--chart-${index + 1})`,
}}
/>
diff --git a/apps/dashboard/src/components/data-table/response-logs/data-table-sheet.tsx b/apps/dashboard/src/components/data-table/response-logs/data-table-sheet.tsx
index db1721cd3..d41d625ec 100644
--- a/apps/dashboard/src/components/data-table/response-logs/data-table-sheet.tsx
+++ b/apps/dashboard/src/components/data-table/response-logs/data-table-sheet.tsx
@@ -21,10 +21,12 @@ export function Sheet({
data,
privateLocations,
onClose,
+ showCopyUrl = true,
}: {
data: ResponseLog | null;
privateLocations?: PrivateLocation[];
onClose: () => void;
+ showCopyUrl?: boolean;
}) {
const { copy, isCopied } = useCopyToClipboard();
if (!data) return null;
@@ -36,22 +38,26 @@ export function Sheet({
<DataTableSheetTitle>Response Logs</DataTableSheetTitle>
</DataTableSheetHeader>
<DataTableBasics data={data} privateLocations={privateLocations} />
- <Separator />
- <DataTableSheetFooter>
- <Button
- variant="outline"
- onClick={() => {
- if (typeof window !== "undefined") {
- copy(window.location.href, {
- withToast: false,
- });
- }
- }}
- >
- Copy Request Log URL
- {isCopied ? <Check /> : <Copy />}
- </Button>
- </DataTableSheetFooter>
+ {showCopyUrl ? (
+ <>
+ <Separator />
+ <DataTableSheetFooter>
+ <Button
+ variant="outline"
+ onClick={() => {
+ if (typeof window !== "undefined") {
+ copy(window.location.href, {
+ withToast: false,
+ });
+ }
+ }}
+ >
+ Copy Request Log URL
+ {isCopied ? <Check /> : <Copy />}
+ </Button>
+ </DataTableSheetFooter>
+ </>
+ ) : null}
</DataTableSheetContent>
</DataTableSheet>
);
diff --git a/apps/dashboard/src/components/forms/onboarding/create-monitor.tsx b/apps/dashboard/src/components/forms/onboarding/create-monitor.tsx
index 83b90d2ad..10866dd72 100644
--- a/apps/dashboard/src/components/forms/onboarding/create-monitor.tsx
+++ b/apps/dashboard/src/components/forms/onboarding/create-monitor.tsx
@@ -10,9 +10,15 @@ import {
FormLabel,
FormMessage,
} from "@openstatus/ui/components/ui/form";
-import { Input } from "@openstatus/ui/components/ui/input";
+import {
+ InputGroup,
+ InputGroupAddon,
+ InputGroupButton,
+ InputGroupInput,
+} from "@openstatus/ui/components/ui/input-group";
import { isTRPCClientError } from "@trpc/client";
-import { useTransition } from "react";
+import { X } from "lucide-react";
+import { useRef, useTransition } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
@@ -37,6 +43,7 @@ export function CreateMonitorForm({
url: "",
},
});
+ const inputRef = useRef<HTMLInputElement | null>(null);
const [isPending, startTransition] = useTransition();
function submitAction(values: FormValues) {
@@ -73,7 +80,30 @@ export function CreateMonitorForm({
<FormItem>
<FormLabel>URL</FormLabel>
<FormControl>
- <Input placeholder="https://api.openstatus.dev" {...field} />
+ <InputGroup>
+ <InputGroupInput
+ placeholder="https://api.openstatus.dev"
+ {...field}
+ ref={(el) => {
+ inputRef.current = el;
+ field.ref(el);
+ }}
+ />
+ {field.value ? (
+ <InputGroupAddon align="inline-end">
+ <InputGroupButton
+ size="icon-xs"
+ aria-label="Clear URL"
+ onClick={() => {
+ field.onChange("");
+ inputRef.current?.focus();
+ }}
+ >
+ <X />
+ </InputGroupButton>
+ </InputGroupAddon>
+ ) : null}
+ </InputGroup>
</FormControl>
<FormMessage />
<FormDescription>
diff --git a/apps/dashboard/src/components/forms/onboarding/create-page.tsx b/apps/dashboard/src/components/forms/onboarding/create-page.tsx
index edfd85060..2f25832fa 100644
--- a/apps/dashboard/src/components/forms/onboarding/create-page.tsx
+++ b/apps/dashboard/src/components/forms/onboarding/create-page.tsx
@@ -2,8 +2,10 @@
// FIXME: use input-group instead
import { InputWithAddons } from "@/components/common/input-with-addons";
+import { ThemePickerPopover } from "@/components/forms/status-page/theme-picker";
import { useTRPC } from "@/lib/trpc/client";
import { zodResolver } from "@hookform/resolvers/zod";
+import { THEME_KEYS, type ThemeKey } from "@openstatus/theme-store";
import { Button } from "@openstatus/ui/components/ui/button";
import {
Form,
@@ -15,10 +17,18 @@ import {
FormMessage,
} from "@openstatus/ui/components/ui/form";
import { Input } from "@openstatus/ui/components/ui/input";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@openstatus/ui/components/ui/select";
import { useDebounce } from "@openstatus/ui/hooks/use-debounce";
import { useQuery } from "@tanstack/react-query";
import { isTRPCClientError } from "@trpc/client";
-import { Plus, X } from "lucide-react";
+import { Laptop, Moon, Plus, Sun, X } from "lucide-react";
+import { useTheme } from "next-themes";
import { useEffect, useTransition } from "react";
import { useFieldArray, useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -27,8 +37,24 @@ import { z } from "zod";
const SLUG_UNIQUE_ERROR_MESSAGE =
"This slug is already taken. Please choose another one.";
+// Keep in sync with `slugSchema` in
+// `packages/db/src/schema/pages/validation.ts`. We can't import that on the
+// client because `@openstatus/db` is server-only. Slugs are stored lowercase
+// (subdomains are case-insensitive), so we restrict input client-side too.
+const SLUG_PATTERN = /^[a-z0-9-]+$/;
+const SLUG_PATTERN_MESSAGE =
+ "Only use digits (0-9), hyphen (-) or lowercase characters (a-z).";
+
+const FORCE_THEME_OPTIONS = [
+ { value: "light", label: "Light", icon: Sun },
+ { value: "dark", label: "Dark", icon: Moon },
+ { value: "system", label: "System", icon: Laptop },
+] as const;
+
const schema = z.object({
- slug: z.string().min(3),
+ slug: z.string().min(3).regex(SLUG_PATTERN, SLUG_PATTERN_MESSAGE),
+ theme: z.enum(THEME_KEYS as [ThemeKey, ...ThemeKey[]]),
+ forceTheme: z.enum(["light", "dark", "system"]),
components: z
.array(
z.object({
@@ -43,18 +69,28 @@ export type FormValues = z.infer<typeof schema>;
export function CreatePageForm({
defaultValues,
onSubmit,
+ onValuesChange,
showComponents = false,
...props
}: Omit<React.ComponentProps<"form">, "onSubmit"> & {
defaultValues?: Partial<FormValues>;
onSubmit: (values: FormValues) => Promise<void>;
+ /** Mirror live form values to a parent that needs them (e.g. a preview). */
+ onValuesChange?: (values: FormValues) => void;
showComponents?: boolean;
}) {
const trpc = useTRPC();
+ const { theme: dashboardTheme, setTheme: setDashboardTheme } = useTheme();
+
const form = useForm<FormValues>({
resolver: zodResolver(schema),
defaultValues: {
slug: "",
+ theme: "default-rounded",
+ forceTheme:
+ dashboardTheme === "dark" || dashboardTheme === "light"
+ ? dashboardTheme
+ : "system",
components: showComponents ? [{ name: "Website" }] : undefined,
...defaultValues,
},
@@ -82,6 +118,15 @@ export function CreatePageForm({
}
}, [isUnique, form]);
+ useEffect(() => {
+ if (!onValuesChange) return;
+ onValuesChange(form.getValues());
+ const sub = form.watch((values) => {
+ onValuesChange(values as FormValues);
+ });
+ return () => sub.unsubscribe();
+ }, [form, onValuesChange]);
+
function submitAction(values: FormValues) {
if (isPending) return;
@@ -140,6 +185,57 @@ export function CreatePageForm({
</FormItem>
)}
/>
+ <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
+ <FormField
+ control={form.control}
+ name="theme"
+ render={({ field }) => (
+ <FormItem className="min-w-0">
+ <FormLabel>Style</FormLabel>
+ <ThemePickerPopover
+ value={field.value}
+ onChange={field.onChange}
+ />
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ <FormField
+ control={form.control}
+ name="forceTheme"
+ render={({ field }) => (
+ <FormItem className="min-w-0">
+ <FormLabel>Mode</FormLabel>
+ <Select
+ value={field.value}
+ onValueChange={(v) => {
+ field.onChange(v);
+ // Mirror to the dashboard so the user previews exactly
+ // what they'll publish. The whole shell flips with them.
+ setDashboardTheme(v);
+ }}
+ >
+ <FormControl>
+ <SelectTrigger className="w-full">
+ <SelectValue placeholder="Mode" />
+ </SelectTrigger>
+ </FormControl>
+ <SelectContent>
+ {FORCE_THEME_OPTIONS.map(({ value, label, icon: Icon }) => (
+ <SelectItem key={value} value={value}>
+ <div className="flex items-center gap-2">
+ <Icon className="size-4" />
+ <span>{label}</span>
+ </div>
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+ </div>
{showComponents && (
<div className="space-y-3">
<FormLabel>Components</FormLabel>
diff --git a/apps/dashboard/src/components/forms/onboarding/question.tsx b/apps/dashboard/src/components/forms/onboarding/question.tsx
index b6c5c65e6..25f5d1f59 100644
--- a/apps/dashboard/src/components/forms/onboarding/question.tsx
+++ b/apps/dashboard/src/components/forms/onboarding/question.tsx
@@ -2,6 +2,14 @@
import { Note } from "@/components/common/note";
import { zodResolver } from "@hookform/resolvers/zod";
+import {
+ BlueskyIcon,
+ GitHubIcon,
+ LinkedInIcon,
+ XIcon,
+ YouTubeIcon,
+} from "@openstatus/icons";
+import { Badge } from "@openstatus/ui/components/ui/badge";
import { Button } from "@openstatus/ui/components/ui/button";
import {
Form,
@@ -17,37 +25,30 @@ import {
RadioGroupItem,
} from "@openstatus/ui/components/ui/radio-group";
import { cn } from "@openstatus/ui/lib/utils";
-import { Check } from "lucide-react";
+import {
+ Check,
+ MoreHorizontal,
+ Newspaper,
+ Search,
+ Sparkles,
+ Users,
+} from "lucide-react";
import { useTransition } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
const sources = [
- {
- id: "social-media",
- title: "Twitter / LinkedIn / Bsky",
- },
- {
- id: "github",
- title: "GitHub",
- },
- {
- id: "google",
- title: "Google Search",
- },
- {
- id: "recommendation",
- title: "Friend / Colleague",
- },
- {
- id: "blog",
- title: "Blog / Article",
- },
- {
- id: "other",
- title: "Other",
- },
+ { id: "search-engine", title: "Search Engine", icon: Search },
+ { id: "github", title: "GitHub", icon: GitHubIcon },
+ { id: "linkedin", title: "LinkedIn", icon: LinkedInIcon },
+ { id: "bluesky", title: "Bluesky", icon: BlueskyIcon },
+ { id: "twitter", title: "X / Twitter", icon: XIcon },
+ { id: "ai-chat", title: "AI Chat", icon: Sparkles },
+ { id: "recommendation", title: "Friend / Colleague", icon: Users },
+ { id: "youtube", title: "YouTube", icon: YouTubeIcon },
+ { id: "blog", title: "Blog / Article", icon: Newspaper },
+ { id: "other", title: "Other", icon: MoreHorizontal },
] as const;
const schema = z.object({
@@ -119,47 +120,71 @@ export function QuestionForm({
<RadioGroup
onValueChange={field.onChange}
defaultValue={field.value}
- className="grid grid-cols-1 gap-4 sm:grid-cols-2"
+ className="flex flex-wrap gap-2"
>
- {sources.map((item) => (
- <FormItem key={item.id} className="flex items-center gap-3">
- <FormControl>
- <RadioGroupItem value={item.id} id={item.id} />
- </FormControl>
- <FormLabel
- htmlFor={item.id}
- className="w-full font-normal"
- >
- {item.title}
- </FormLabel>
- </FormItem>
- ))}
+ {sources.map((item) => {
+ const selected = field.value === item.id;
+ return (
+ <FormItem key={item.id} className="space-y-0">
+ <FormControl>
+ <RadioGroupItem
+ value={item.id}
+ id={item.id}
+ className="sr-only"
+ />
+ </FormControl>
+ <FormLabel
+ htmlFor={item.id}
+ className="cursor-pointer font-normal"
+ >
+ <Badge
+ variant={selected ? "default" : "outline"}
+ className={cn(
+ "transition-colors",
+ !selected &&
+ "text-muted-foreground hover:border-foreground hover:text-foreground",
+ )}
+ >
+ <item.icon className="size-3" />
+ {item.title}
+ </Badge>
+ </FormLabel>
+ </FormItem>
+ );
+ })}
</RadioGroup>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
- {watchSource === "other" && (
- <FormField
- control={form.control}
- name="other"
- render={({ field }) => (
- <FormItem>
- <FormControl>
- <Input
- placeholder="Please specify"
- className="sm:w-1/2"
- {...field}
- />
- </FormControl>
- </FormItem>
- )}
- />
- )}
- <Button size="sm" type="submit" disabled={isPending}>
- {isPending ? "Submitting..." : "Submit"}
- </Button>
+ <div className="flex items-center gap-2">
+ {watchSource === "other" && (
+ <FormField
+ control={form.control}
+ name="other"
+ render={({ field }) => (
+ <FormItem>
+ <FormControl>
+ <Input
+ placeholder="Please specify..."
+ className="w-full"
+ {...field}
+ />
+ </FormControl>
+ </FormItem>
+ )}
+ />
+ )}
+ <Button
+ size="sm"
+ type="submit"
+ disabled={isPending || !watchSource}
+ variant="default"
+ >
+ {isPending ? "Submitting..." : "Submit"}
+ </Button>
+ </div>
</form>
</Form>
);
diff --git a/apps/dashboard/src/components/forms/status-page/form-appearance.tsx b/apps/dashboard/src/components/forms/status-page/form-appearance.tsx
index 6b6f7bbfa..31f8be51d 100644
--- a/apps/dashboard/src/components/forms/status-page/form-appearance.tsx
+++ b/apps/dashboard/src/components/forms/status-page/form-appearance.tsx
@@ -11,19 +11,10 @@ import {
FormCardHeader,
FormCardTitle,
} from "@/components/forms/form-card";
+import { ThemePickerPopover } from "@/components/forms/status-page/theme-picker";
import { zodResolver } from "@hookform/resolvers/zod";
-import { THEME_KEYS } from "@openstatus/theme-store";
-import { THEMES } from "@openstatus/theme-store";
import type { ThemeKey } from "@openstatus/theme-store";
import { Button } from "@openstatus/ui/components/ui/button";
-import {
- Command,
- CommandEmpty,
- CommandGroup,
- CommandInput,
- CommandItem,
- CommandList,
-} from "@openstatus/ui/components/ui/command";
import {
Form,
FormControl,
@@ -33,11 +24,6 @@ import {
FormLabel,
FormMessage,
} from "@openstatus/ui/components/ui/form";
-import {
- Popover,
- PopoverContent,
- PopoverTrigger,
-} from "@openstatus/ui/components/ui/popover";
import {
Select,
SelectContent,
@@ -45,10 +31,8 @@ import {
SelectTrigger,
SelectValue,
} from "@openstatus/ui/components/ui/select";
-import { cn } from "@openstatus/ui/lib/utils";
import { isTRPCClientError } from "@trpc/client";
import { ArrowUpRight, Laptop, Moon, Sun } from "lucide-react";
-import { Check, ChevronsUpDown } from "lucide-react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
@@ -157,66 +141,12 @@ export function FormAppearance({
control={form.control}
name="configuration.theme"
render={({ field }) => (
- <FormItem>
+ <FormItem className="min-w-0">
<FormLabel>Style</FormLabel>
- <Popover>
- <PopoverTrigger asChild>
- <FormControl>
- <Button
- id="community-theme"
- variant="outline"
- role="combobox"
- className={cn(
- "w-full justify-between",
- !field.value && "text-muted-foreground",
- )}
- >
- <span className="truncate">
- {THEMES[field.value as ThemeKey]?.name ||
- "Select a theme"}
- </span>
- <ChevronsUpDown className="opacity-50" />
- </Button>
- </FormControl>
- </PopoverTrigger>
- <PopoverContent className="p-0" align="start">
- <Command>
- <CommandInput
- placeholder="Search themes..."
- className="h-9"
- />
- <CommandList>
- <CommandEmpty>No themes found.</CommandEmpty>
- <CommandGroup>
- {THEME_KEYS.map((theme) => {
- const { name, author } = THEMES[theme];
- return (
- <CommandItem
- value={theme}
- key={theme}
- keywords={[theme, name, author.name]}
- onSelect={(v) => field.onChange(v)}
- >
- <span className="truncate">{name}</span>
- <span className="truncate font-commit-mono text-muted-foreground text-xs">
- by {author.name}
- </span>
- <Check
- className={cn(
- "ml-auto",
- theme === field.value
- ? "opacity-100"
- : "opacity-0",
- )}
- />
- </CommandItem>
- );
- })}
- </CommandGroup>
- </CommandList>
- </Command>
- </PopoverContent>
- </Popover>
+ <ThemePickerPopover
+ value={field.value as ThemeKey}
+ onChange={field.onChange}
+ />
<FormMessage />
<FormDescription>Choose a theme to apply.</FormDescription>
</FormItem>
diff --git a/apps/dashboard/src/components/forms/status-page/form-general.tsx b/apps/dashboard/src/components/forms/status-page/form-general.tsx
index 2d09bc98b..37083fb38 100644
--- a/apps/dashboard/src/components/forms/status-page/form-general.tsx
+++ b/apps/dashboard/src/components/forms/status-page/form-general.tsx
@@ -38,6 +38,14 @@ import { z } from "zod";
const SLUG_UNIQUE_ERROR_MESSAGE =
"This slug is already taken. Please choose another one.";
+// Keep in sync with `slugSchema` in
+// `packages/db/src/schema/pages/validation.ts`. We can't import that on the
+// client because `@openstatus/db` is server-only. Slugs are stored lowercase
+// (subdomains are case-insensitive), so we restrict input client-side too.
+const SLUG_PATTERN = /^[a-z0-9-]+$/;
+const SLUG_PATTERN_MESSAGE =
+ "Only use digits (0-9), hyphen (-) or lowercase characters (a-z).";
+
function formatSlug(title: string) {
return title
.toLowerCase()
@@ -47,7 +55,10 @@ function formatSlug(title: string) {
const schema = z.object({
title: z.string().min(1, "Title is required"),
- slug: z.string().min(3, "Slug is required"),
+ slug: z
+ .string()
+ .min(3, "Slug is required")
+ .regex(SLUG_PATTERN, SLUG_PATTERN_MESSAGE),
icon: z.string().optional(),
description: z.string().optional(),
});
diff --git a/apps/dashboard/src/components/forms/status-page/theme-picker.tsx b/apps/dashboard/src/components/forms/status-page/theme-picker.tsx
new file mode 100644
index 000000000..f6ae5fb14
--- /dev/null
+++ b/apps/dashboard/src/components/forms/status-page/theme-picker.tsx
@@ -0,0 +1,130 @@
+"use client";
+
+import { Link } from "@/components/common/link";
+import { THEMES, THEME_KEYS, type ThemeKey } from "@openstatus/theme-store";
+import { Button } from "@openstatus/ui/components/ui/button";
+import {
+ Command,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+} from "@openstatus/ui/components/ui/command";
+import { FormControl } from "@openstatus/ui/components/ui/form";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@openstatus/ui/components/ui/popover";
+import { cn } from "@openstatus/ui/lib/utils";
+import { Check, ChevronsUpDown } from "lucide-react";
+import { useTheme } from "next-themes";
+import { useEffect, useState } from "react";
+
+// Color swatches shown next to each theme option. Mirrors the playground
+// convention at `apps/status-page/.../public/client.tsx`.
+const SWATCH_VARS = [
+ "--primary",
+ "--success",
+ "--warning",
+ "--destructive",
+ "--info",
+] as const;
+
+export function ThemeSwatches({ themeKey }: { themeKey: ThemeKey }) {
+ const { resolvedTheme } = useTheme();
+ // next-themes resolves `system` only on the client, so SSR has no
+ // resolvedTheme. Render the light palette until mount to keep the
+ // server HTML and the first client render in agreement, then settle to
+ // the resolved mode.
+ const [mounted, setMounted] = useState(false);
+ useEffect(() => setMounted(true), []);
+ const theme = THEMES[themeKey] ?? THEMES.default;
+ const palette =
+ mounted && resolvedTheme === "dark" ? theme.dark : theme.light;
+ return (
+ <div className="-space-x-1 flex shrink-0 items-center">
+ {SWATCH_VARS.map((cssVar) => (
+ <span
+ key={cssVar}
+ aria-hidden
+ className="size-3 rounded-full border border-border ring-1 ring-background"
+ style={{ background: palette[cssVar] }}
+ />
+ ))}
+ </div>
+ );
+}
+
+export function ThemePickerPopover({
+ value,
+ onChange,
+}: {
+ value: ThemeKey;
+ onChange: (value: ThemeKey) => void;
+}) {
+ const [open, setOpen] = useState(false);
+ return (
+ <Popover open={open} onOpenChange={setOpen}>
+ <PopoverTrigger asChild>
+ <FormControl>
+ <Button
+ variant="outline"
+ role="combobox"
+ className={cn(
+ "w-full min-w-0 justify-between",
+ !value && "text-muted-foreground",
+ )}
+ >
+ <div className="flex min-w-0 flex-1 items-center gap-2">
+ <ThemeSwatches themeKey={value} />
+ <span className="truncate">
+ {THEMES[value]?.name ?? "Select a theme"}
+ </span>
+ </div>
+ <ChevronsUpDown className="shrink-0 opacity-50" />
+ </Button>
+ </FormControl>
+ </PopoverTrigger>
+ <PopoverContent className="p-0" align="start">
+ <Command>
+ <CommandInput placeholder="Search themes..." className="h-9" />
+ <CommandList>
+ <CommandEmpty>
+ No themes found. Browse{" "}
+ <Link href="https://themes.openstatus.dev">
+ themes.openstatus.dev
+ </Link>
+ </CommandEmpty>
+ <CommandGroup>
+ {THEME_KEYS.map((key) => {
+ const { name } = THEMES[key];
+ return (
+ <CommandItem
+ key={key}
+ value={key}
+ keywords={[key, name]}
+ onSelect={(v) => {
+ onChange(v as ThemeKey);
+ setOpen(false);
+ }}
+ >
+ <ThemeSwatches themeKey={key} />
+ <span className="truncate">{name}</span>
+ <Check
+ className={cn(
+ "ml-auto",
+ key === value ? "opacity-100" : "opacity-0",
+ )}
+ />
+ </CommandItem>
+ );
+ })}
+ </CommandGroup>
+ </CommandList>
+ </Command>
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/apps/dashboard/src/components/layout/auth-layout.tsx b/apps/dashboard/src/components/layout/auth-layout.tsx
index 0726d5f68..76284f01a 100644
--- a/apps/dashboard/src/components/layout/auth-layout.tsx
+++ b/apps/dashboard/src/components/layout/auth-layout.tsx
@@ -1,41 +1,59 @@
+import {
+ SHELL_CONTENT_COLUMN,
+ SHELL_FORM_COLUMN,
+} from "@/components/layout/shell-columns";
+import { Wordmark } from "@/components/layout/wordmark";
+import { cn } from "@/lib/utils";
import { Button } from "@openstatus/ui/components/ui/button";
import { BookOpen } from "lucide-react";
-import Image from "next/image";
export function AuthLayout({ children }: { children: React.ReactNode }) {
return (
<div className="relative grid min-h-screen grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-5">
+ <div className="absolute top-4 left-4 z-10">
+ <Wordmark size={24} showText />
+ </div>
<Button
- asChild
size="sm"
variant="outline"
className="absolute top-4 right-4 z-10"
+ asChild
>
<a href="https://docs.openstatus.dev" target="_blank" rel="noreferrer">
- <BookOpen className="mr-2 h-4 w-4" />
+ <BookOpen />
Documentation
</a>
</Button>
- <aside className="col-span-1 flex w-full flex-col gap-4 border border-border bg-sidebar p-4 backdrop-blur-[2px] md:p-8 xl:col-span-2">
- <a href="https://openstatus.dev" className="relative h-8 w-8">
- <Image
- src="https://openstatus.dev/icon.png"
- alt="OpenStatus"
- height={32}
- width={32}
- className="rounded-full border border-border"
- />
- </a>
- <div className="mx-auto flex w-full max-w-lg flex-1 flex-col justify-center gap-8 text-center md:text-left">
+ {/*
+ Column widths mirror onboarding: form column = `xl:col-span-2`,
+ content column = `xl:col-span-3`. Both login and onboarding
+ keep the form on the left, so the grids feel aligned when
+ navigating between them.
+ */}
+ <main
+ className={cn(
+ "container col-span-1 mx-auto flex items-center justify-center md:col-span-1",
+ SHELL_FORM_COLUMN,
+ )}
+ >
+ {children}
+ </main>
+ <aside
+ className={cn(
+ "col-span-1 flex w-full flex-col gap-4 border border-border bg-sidebar p-4 backdrop-blur-[2px] md:p-8",
+ SHELL_CONTENT_COLUMN,
+ )}
+ >
+ <div className="mx-auto flex w-full max-w-2xl flex-1 flex-col justify-center gap-8 text-center md:text-left">
<div className="mx-auto grid gap-3">
<h1 className="font-cal text-3xl text-foreground">
- Your Status Page in Minutes
+ Your status page, live in minutes.
</h1>
- <p className="text-muted-foreground text-sm">
- Communicate incidents, prove compliance readiness, and monitor
- uptime from 28 global regions. Open source and free to start.{" "}
+ <p className="font-commit-mono text-muted-foreground">
+ Communicate incidents, prove uptime, and monitor every endpoint
+ from 28 regions. Open source. Free to start.
</p>
- <p className="text-muted-foreground text-sm">
+ <p className="font-commit-mono text-muted-foreground">
Coming from{" "}
<a
href="https://openstatus.dev/guides/migrate-from-atlassian-statuspage"
@@ -69,9 +87,6 @@ export function AuthLayout({ children }: { children: React.ReactNode }) {
</div>
<div className="md:h-8" />
</aside>
- <main className="container col-span-1 mx-auto flex items-center justify-center md:col-span-1 xl:col-span-3">
- {children}
- </main>
</div>
);
}
diff --git a/apps/dashboard/src/components/layout/onboarding-layout.tsx b/apps/dashboard/src/components/layout/onboarding-layout.tsx
new file mode 100644
index 000000000..2c1d5df83
--- /dev/null
+++ b/apps/dashboard/src/components/layout/onboarding-layout.tsx
@@ -0,0 +1,337 @@
+"use client";
+
+import {
+ SHELL_CONTENT_COLUMN,
+ SHELL_FORM_COLUMN,
+} from "@/components/layout/shell-columns";
+import { Wordmark } from "@/components/layout/wordmark";
+import { NavFeedback } from "@/components/nav/nav-feedback";
+import { NavLogout } from "@/components/nav/nav-logout";
+import { cn } from "@/lib/utils";
+import { Button } from "@openstatus/ui/components/ui/button";
+import {
+ ButtonGroup,
+ ButtonGroupText,
+} from "@openstatus/ui/components/ui/button-group";
+import { useCopyToClipboard } from "@openstatus/ui/hooks/use-copy-to-clipboard";
+import { ArrowUpRight, Check, Copy } from "lucide-react";
+
+type StepStatus = "current" | "completed" | "upcoming";
+
+export type OnboardingStep = {
+ id: string;
+ label: string;
+ status: StepStatus;
+ icon?: React.ReactNode;
+};
+
+export function OnboardingLayout({
+ className,
+ children,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ className={cn(
+ "flex min-h-dvh flex-col bg-background md:h-dvh md:min-h-0 md:overflow-hidden",
+ className,
+ )}
+ {...props}
+ >
+ <header className="flex h-14 shrink-0 items-center justify-between border-border border-b px-4 md:px-6">
+ <Wordmark size={24} showText />
+ <div className="flex items-center gap-2">
+ <NavFeedback />
+ <NavLogout />
+ </div>
+ </header>
+ <main className="flex flex-1 flex-col md:min-h-0">{children}</main>
+ </div>
+ );
+}
+
+export function OnboardingStepper({
+ steps,
+ className,
+ ...props
+}: React.ComponentProps<"nav"> & { steps: OnboardingStep[] }) {
+ return (
+ <nav
+ aria-label="Onboarding progress"
+ className={cn("w-full", className)}
+ {...props}
+ >
+ <ol className="flex w-full items-stretch gap-3">
+ {steps.map((step) => {
+ const active =
+ step.status === "current" || step.status === "completed";
+ return (
+ <li
+ key={step.id}
+ className="flex flex-1 flex-col gap-1.5"
+ aria-current={step.status === "current" ? "step" : undefined}
+ >
+ <div
+ className={cn(
+ "h-0.5 w-full rounded-full transition-colors",
+ active ? "bg-foreground" : "bg-muted",
+ )}
+ aria-hidden
+ />
+ <div
+ className={cn(
+ "flex items-center gap-1.5 font-commit-mono text-xs tracking-tight transition-colors [&>svg]:size-3 [&>svg]:shrink-0",
+ active ? "text-foreground" : "text-muted-foreground/70",
+ )}
+ >
+ {step.icon}
+ <span>{step.label}</span>
+ </div>
+ </li>
+ );
+ })}
+ </ol>
+ </nav>
+ );
+}
+
+export function OnboardingShell({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ className={cn(
+ "grid w-full flex-1 grid-cols-1 md:min-h-0 md:grid-cols-2 xl:grid-cols-5",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingFormColumn({
+ className,
+ ...props
+}: React.ComponentProps<"section">) {
+ return (
+ <section
+ className={cn(
+ "col-span-1 flex w-full flex-col gap-6 px-4 py-8 md:min-h-0 md:overflow-y-auto md:px-8 md:py-32",
+ SHELL_FORM_COLUMN,
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingResultColumn({
+ className,
+ ...props
+}: React.ComponentProps<"section">) {
+ return (
+ <section
+ className={cn(
+ "col-span-1 flex w-full flex-col gap-3 border-border border-t bg-sidebar p-4 md:min-h-0 md:overflow-hidden md:border-t-0 md:border-l md:p-8",
+ SHELL_CONTENT_COLUMN,
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+// =============================================================================
+// Compound: form-column header
+// Use as: <OnboardingStepHeader><OnboardingStepTitle/><OnboardingStepDescription/></OnboardingStepHeader>
+// Mirrors auth/login: same `font-cal` heading + `font-commit-mono` muted lead.
+// =============================================================================
+
+export function OnboardingStepHeader({
+ className,
+ ...props
+}: React.ComponentProps<"header">) {
+ return <header className={cn("space-y-2", className)} {...props} />;
+}
+
+export function OnboardingStepTitle({
+ className,
+ ...props
+}: React.ComponentProps<"h1">) {
+ return (
+ <h1
+ className={cn(
+ "font-cal text-2xl text-foreground tracking-tight",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingStepDescription({
+ className,
+ ...props
+}: React.ComponentProps<"p">) {
+ return (
+ <p
+ className={cn(
+ "text-pretty font-commit-mono text-muted-foreground text-sm",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingResultHeading({
+ className,
+ ...props
+}: React.ComponentProps<"h2">) {
+ return (
+ <h2
+ className={cn(
+ "font-commit-mono font-medium text-foreground text-sm uppercase",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingActions({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div className={cn("flex items-center gap-2", className)} {...props} />
+ );
+}
+
+// =============================================================================
+// Compound: preview placeholder
+// Shared shell for the right-column previews (Step1 checks, Step2 iframe).
+// Renders decorative content behind a backdrop-blurred hint card.
+//
+// Use as:
+// <OnboardingPreviewPlaceholder>
+// <OnboardingPreviewPlaceholderContent>{decorativeContent}</...>
+// <OnboardingPreviewPlaceholderOverlay>
+// <OnboardingPreviewPlaceholderText>{hint}</...>
+// </...>
+// </OnboardingPreviewPlaceholder>
+// =============================================================================
+
+export function OnboardingPreviewPlaceholder({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ className={cn(
+ "relative overflow-hidden rounded-md border border-border bg-background md:min-h-0 md:flex-1",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingPreviewPlaceholderContent({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ className={cn(
+ "pointer-events-none flex select-none md:min-h-0",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingPreviewPlaceholderOverlay({
+ className,
+ ...props
+}: React.ComponentProps<"div">) {
+ return (
+ <div
+ className={cn(
+ "absolute inset-0 flex flex-col items-center justify-center gap-2 bg-gradient-to-b from-0% from-transparent to-90% to-background p-2",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+export function OnboardingPreviewPlaceholderText({
+ className,
+ ...props
+}: React.ComponentProps<"p">) {
+ return (
+ <p
+ className={cn(
+ "max-w-xs text-pretty rounded-md border border-border p-2 text-center text-foreground text-sm backdrop-blur-sm",
+ className,
+ )}
+ {...props}
+ />
+ );
+}
+
+// =============================================================================
+// Locked-summary input
+// Shown after the step's form has been submitted — read-only display of the
+// committed value with copy + open affordances.
+// =============================================================================
+
+export function OnboardingLockedSummary({
+ value,
+ href,
+ helper,
+ className,
+ ...props
+}: Omit<React.ComponentProps<"div">, "children"> & {
+ value: string;
+ /** Optional external link target. When provided, an "Open" button is added. */
+ href?: string;
+ helper?: React.ReactNode;
+}) {
+ const { copy, isCopied } = useCopyToClipboard();
+ return (
+ <div className={cn("space-y-3", className)} {...props}>
+ <ButtonGroup className="w-full">
+ <ButtonGroupText className="min-w-0 flex-1 justify-start">
+ <code className="truncate font-mono text-foreground text-sm">
+ {value}
+ </code>
+ <Check className="size-3 shrink-0 text-success" />
+ </ButtonGroupText>
+ <Button
+ variant="outline"
+ onClick={() => copy(value, { withToast: false })}
+ >
+ {isCopied ? (
+ <Check className="size-3" />
+ ) : (
+ <Copy className="size-3" />
+ )}
+ </Button>
+ {href ? (
+ <Button variant="outline" asChild>
+ <a href={href} target="_blank" rel="noopener noreferrer">
+ Open <ArrowUpRight className="size-3" />
+ </a>
+ </Button>
+ ) : null}
+ </ButtonGroup>
+ {helper ? (
+ <p className="text-muted-foreground text-xs">{helper}</p>
+ ) : null}
+ </div>
+ );
+}
diff --git a/apps/dashboard/src/components/layout/shell-columns.ts b/apps/dashboard/src/components/layout/shell-columns.ts
new file mode 100644
index 000000000..2d7513278
--- /dev/null
+++ b/apps/dashboard/src/components/layout/shell-columns.ts
@@ -0,0 +1,12 @@
+/**
+ * Shared column-span tokens for the login + onboarding split-shells.
+ * Keeping them in one place ensures the form column has the same width
+ * across both pages (onboarding form is on the left, login form is on
+ * the right), so the grids feel visually aligned when navigating
+ * between them.
+ *
+ * The grid is `xl:grid-cols-5`. Below `xl` it falls back to a 50/50
+ * `md:grid-cols-2` split or single column on mobile.
+ */
+export const SHELL_FORM_COLUMN = "xl:col-span-2";
+export const SHELL_CONTENT_COLUMN = "xl:col-span-3";
diff --git a/apps/dashboard/src/components/layout/wordmark.tsx b/apps/dashboard/src/components/layout/wordmark.tsx
new file mode 100644
index 000000000..087045f3f
--- /dev/null
+++ b/apps/dashboard/src/components/layout/wordmark.tsx
@@ -0,0 +1,45 @@
+import { cn } from "@/lib/utils";
+import Image from "next/image";
+
+export function Wordmark({
+ size = 24,
+ showText = false,
+ className,
+ href = "https://openstatus.dev",
+ target = "_blank",
+ rel = "noreferrer",
+ ...props
+}: Omit<React.ComponentProps<"a">, "children"> & {
+ size?: 24 | 32;
+ showText?: boolean;
+}) {
+ return (
+ <a
+ href={href}
+ target={target}
+ rel={rel}
+ className={cn("flex items-center gap-2", className)}
+ {...props}
+ >
+ <span className="relative block" style={{ height: size, width: size }}>
+ <Image
+ src="https://openstatus.dev/icon.png"
+ alt="openstatus"
+ height={size}
+ width={size}
+ className="rounded-full border border-border"
+ />
+ </span>
+ {showText ? (
+ <span
+ className={cn(
+ "font-cal text-foreground",
+ size === 32 ? "text-base" : "text-sm",
+ )}
+ >
+ openstatus
+ </span>
+ ) : null}
+ </a>
+ );
+}
diff --git a/apps/dashboard/src/components/nav/nav-logout.tsx b/apps/dashboard/src/components/nav/nav-logout.tsx
new file mode 100644
index 000000000..c37a57682
--- /dev/null
+++ b/apps/dashboard/src/components/nav/nav-logout.tsx
@@ -0,0 +1,25 @@
+"use client";
+
+import { Button } from "@openstatus/ui/components/ui/button";
+import { LogOut } from "lucide-react";
+import { signOut } from "next-auth/react";
+
+export function NavLogout({
+ onClick,
+ ...props
+}: Omit<React.ComponentProps<typeof Button>, "children">) {
+ return (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={(event) => {
+ onClick?.(event);
+ if (!event.defaultPrevented) signOut();
+ }}
+ {...props}
+ >
+ <LogOut className="size-3" />
+ Log out
+ </Button>
+ );
+}
diff --git a/apps/dashboard/src/components/onboarding/checks-table-adapter.ts b/apps/dashboard/src/components/onboarding/checks-table-adapter.ts
new file mode 100644
index 000000000..e07e9673a
--- /dev/null
+++ b/apps/dashboard/src/components/onboarding/checks-table-adapter.ts
@@ -0,0 +1,87 @@
+import type {
+ CheckResult,
+ CheckResultSuccess,
+} from "@openstatus/services/monitor";
+
+import type { OnboardingChecksRow } from "./checks-table";
+
+function calculatePhases(timing: CheckResultSuccess["timing"]) {
+ return {
+ dns: timing.dnsDone - timing.dnsStart,
+ connect: timing.connectDone - timing.connectStart,
+ tls: timing.tlsHandshakeDone - timing.tlsHandshakeStart,
+ ttfb: timing.firstByteDone - timing.firstByteStart,
+ transfer: timing.transferDone - timing.transferStart,
+ };
+}
+
+/**
+ * Adapt a Go-checker preview result into the `ResponseLog` shape
+ * `getColumns` and `<Sheet>` expect. The synthesized row is "rich enough"
+ * for both the table cells and the row-detail drawer.
+ *
+ * - `id` is set to `region` — synthetic but stable for selection.
+ * - `requestStatus` derived from status + state.
+ * - `timing` is the raw start/done timestamps that `<HoverCardTiming>`
+ * diffs into phases.
+ * - `workspaceId` is intentionally `""` — no current row renderer
+ * (`columns.tsx`, `data-table-basics.tsx`, `data-table-sheet.tsx`)
+ * reads it. If a future renderer constructs a URL from `workspaceId`,
+ * plumb the real id through here.
+ */
+export function checkResultToResponseLog(
+ result: CheckResult,
+ monitorId: number,
+ monitorUrl: string,
+): OnboardingChecksRow {
+ const now = result.timestamp ?? Date.now();
+
+ if (result.state === "error") {
+ return {
+ type: "http",
+ id: result.region,
+ latency: 0,
+ statusCode: 0,
+ requestStatus: "error",
+ region: result.region,
+ timing: null,
+ timestamp: now,
+ cronTimestamp: now,
+ trigger: "api",
+ monitorId: String(monitorId),
+ url: monitorUrl,
+ error: true,
+ message: result.message,
+ headers: null,
+ body: null,
+ assertions: null,
+ workspaceId: "",
+ } satisfies OnboardingChecksRow;
+ }
+
+ const requestStatus =
+ result.status >= 400 ? "error" : result.status >= 200 ? "success" : "error";
+
+ const phases = result.timing ? calculatePhases(result.timing) : null;
+
+ return {
+ type: "http",
+ id: result.region,
+ latency: result.latency,
+ statusCode: result.status,
+ requestStatus,
+ region: result.region,
+ timing: phases,
+ timestamp: now,
+ cronTimestamp: now,
+ trigger: "api",
+ monitorId: String(monitorId),
+ url: monitorUrl,
+ error: false,
+ message: null,
+ headers: result.headers ?? null,
+ body: result.body ?? null,
+ assertions: null,
+ workspaceId: "",
+ } satisfies OnboardingChecksRow;
+}
diff --git a/apps/dashboard/src/components/onboarding/checks-table.tsx b/apps/dashboard/src/components/onboarding/checks-table.tsx
new file mode 100644
index 000000000..686c6429c
--- /dev/null
+++ b/apps/dashboard/src/components/onboarding/checks-table.tsx
@@ -0,0 +1,177 @@
+"use client";
+
+import { getColumns } from "@/components/data-table/response-logs/columns";
+import { Sheet } from "@/components/data-table/response-logs/data-table-sheet";
+import { DataTableSkeleton } from "@/components/ui/data-table/data-table-skeleton";
+import type { RouterOutputs } from "@openstatus/api";
+import { Button } from "@openstatus/ui/components/ui/button";
+import {
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from "@openstatus/ui/components/ui/table";
+import { cn } from "@openstatus/ui/lib/utils";
+import {
+ type ColumnDef,
+ flexRender,
+ getCoreRowModel,
+ useReactTable,
+} from "@tanstack/react-table";
+import { AlertTriangle, RefreshCw } from "lucide-react";
+import { useState } from "react";
+
+// Use the wider `get`-shape so the row also satisfies the Sheet's input.
+// The column defs are typed against `list` shape, but every list field
+// is also present on `get`, so casting is safe.
+export type OnboardingChecksRow =
+ RouterOutputs["tinybird"]["get"]["data"][number];
+
+const COLUMNS = getColumns([]) as unknown as ColumnDef<OnboardingChecksRow>[];
+
+export function OnboardingChecksTable({
+ rows,
+ totalRegions,
+ isStreaming,
+ allFailed,
+ url,
+ onRetry,
+ className,
+ ...props
+}: Omit<React.ComponentProps<"div">, "children"> & {
+ rows: OnboardingChecksRow[];
+ totalRegions: number;
+ isStreaming: boolean;
+ allFailed: boolean;
+ url?: string;
+ onRetry: () => void;
+}) {
+ // Track selection by row id so new rows arriving via streaming don't
+ // make the Sheet point at a stale object reference.
+ const [selectedId, setSelectedId] = useState<string | null>(null);
+
+ const table = useReactTable({
+ data: rows,
+ columns: COLUMNS,
+ getCoreRowModel: getCoreRowModel(),
+ initialState: {
+ columnVisibility: { trigger: false },
+ },
+ });
+
+ const selected =
+ selectedId == null ? null : rows.find((r) => r.id === selectedId) ?? null;
+
+ if (allFailed) {
+ return (
+ <div
+ className={cn(
+ "flex flex-col items-center gap-3 rounded-md border border-border bg-muted/30 p-6 text-center",
+ className,
+ )}
+ {...props}
+ >
+ <AlertTriangle className="size-5 text-destructive" />
+ <div className="space-y-1">
+ <p className="font-medium text-foreground text-sm">
+ Couldn&apos;t reach {url ? <code>{url}</code> : "your URL"}
+ </p>
+ <p className="text-muted-foreground text-xs">
+ Common causes: the URL is internal, blocks our checkers, or has a
+ typo.
+ </p>
+ </div>
+ <Button variant="outline" size="sm" onClick={onRetry}>
+ <RefreshCw className="size-3" />
+ Retry
+ </Button>
+ </div>
+ );
+ }
+
+ if (rows.length === 0 && isStreaming) {
+ return (
+ <div
+ className={cn(
+ "overflow-auto rounded-md border border-border bg-background md:min-h-0 md:flex-1",
+ className,
+ )}
+ {...props}
+ >
+ <DataTableSkeleton rows={Math.min(totalRegions, 8)} />
+ </div>
+ );
+ }
+
+ return (
+ <>
+ <div
+ className={cn(
+ "overflow-auto rounded-md border border-border bg-background md:min-h-0 md:flex-1",
+ className,
+ )}
+ {...props}
+ >
+ <table className="w-full caption-bottom text-sm">
+ <TableHeader className="sticky top-0 z-10 bg-muted">
+ {table.getHeaderGroups().map((headerGroup) => (
+ <TableRow key={headerGroup.id} className="hover:bg-transparent">
+ {headerGroup.headers.map((header) => (
+ <TableHead key={header.id}>
+ {header.isPlaceholder
+ ? null
+ : flexRender(
+ header.column.columnDef.header,
+ header.getContext(),
+ )}
+ </TableHead>
+ ))}
+ </TableRow>
+ ))}
+ </TableHeader>
+ <TableBody>
+ {table.getRowModel().rows.map((row) => (
+ <TableRow
+ key={row.id}
+ className="cursor-pointer"
+ onClick={() => setSelectedId(row.original.id ?? null)}
+ >
+ {row.getVisibleCells().map((cell) => (
+ <TableCell
+ key={cell.id}
+ className={cn(
+ (
+ cell.column.columnDef.meta as
+ | { cellClassName?: string }
+ | undefined
+ )?.cellClassName,
+ )}
+ >
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
+ </TableCell>
+ ))}
+ </TableRow>
+ ))}
+ {isStreaming && rows.length < totalRegions ? (
+ <TableRow className="hover:bg-transparent">
+ <TableCell
+ colSpan={table.getVisibleLeafColumns().length}
+ className="text-center text-muted-foreground text-xs"
+ >
+ Streaming results from {totalRegions - rows.length} more
+ region{totalRegions - rows.length === 1 ? "" : "s"}…
+ </TableCell>
+ </TableRow>
+ ) : null}
+ </TableBody>
+ </table>
+ </div>
+ <Sheet
+ data={selected}
+ onClose={() => setSelectedId(null)}
+ showCopyUrl={false}
+ />
+ </>
+ );
+}
diff --git a/apps/dashboard/src/components/onboarding/feature-badges.tsx b/apps/dashboard/src/components/onboarding/feature-badges.tsx
new file mode 100644
index 000000000..2e80d8e97
--- /dev/null
+++ b/apps/dashboard/src/components/onboarding/feature-badges.tsx
@@ -0,0 +1,223 @@
+"use client";
+
+import { QuestionForm } from "@/components/forms/onboarding/question";
+import { OnboardingResultHeading } from "@/components/layout/onboarding-layout";
+import { cn } from "@/lib/utils";
+import { ModelContextProtocolIcon, SlackIcon } from "@openstatus/icons";
+import {
+ ArrowUpRight,
+ Bell,
+ BookOpen,
+ Braces,
+ FileText,
+ Globe,
+ Palette,
+ ScanEye,
+ ScrollText,
+ ServerCog,
+ Shield,
+ Terminal,
+ UserPlus,
+ Users,
+ Zap,
+} from "lucide-react";
+import Link from "next/link";
+
+type FeatureLinkItem = {
+ name: string;
+ href: string;
+ icon: React.ComponentType<{ className?: string }>;
+ external?: boolean;
+};
+
+const DOCS = "https://docs.openstatus.dev";
+const WEB = "https://www.openstatus.dev";
+
+const FEATURE_CATEGORIES: { label: string; items: FeatureLinkItem[] }[] = [
+ {
+ label: "Resources",
+ items: [
+ { name: "Docs", href: DOCS, icon: BookOpen, external: true },
+ {
+ name: "Changelog",
+ href: `${WEB}/changelog`,
+ icon: ScrollText,
+ external: true,
+ },
+ {
+ name: "Blog",
+ href: `${WEB}/blog`,
+ icon: FileText,
+ external: true,
+ },
+ ],
+ },
+ {
+ label: "Monitoring",
+ items: [
+ {
+ name: "OpenTelemetry",
+ href: `${DOCS}/guides/how-to-export-metrics-to-otlp-endpoint`,
+ icon: Zap,
+ external: true,
+ },
+ {
+ name: "Private locations",
+ href: `${DOCS}/tutorial/how-to-create-private-location`,
+ icon: ServerCog,
+ external: true,
+ },
+ {
+ name: "Notifications",
+ href: `${DOCS}/reference/notification`,
+ icon: Bell,
+ external: true,
+ },
+ ],
+ },
+ {
+ label: "Status page",
+ items: [
+ {
+ name: "Custom domain",
+ href: `${DOCS}/reference/status-page#custom-domain`,
+ icon: Globe,
+ external: true,
+ },
+ {
+ name: "Themes Store",
+ href: "https://themes.openstatus.dev",
+ icon: Palette,
+ external: true,
+ },
+ {
+ name: "Protection",
+ href: `${DOCS}/reference/status-page#password-basic-auth`,
+ icon: Shield,
+ external: true,
+ },
+ {
+ name: "Slack agent",
+ href: `${DOCS}/tutorial/how-to-setup-slack-agent`,
+ icon: SlackIcon,
+ external: true,
+ },
+ {
+ name: "Subscribers",
+ href: `${DOCS}/reference/subscriber`,
+ icon: Users,
+ external: true,
+ },
+ ],
+ },
+ {
+ label: "Developer",
+ items: [
+ {
+ name: "REST API",
+ href: `${DOCS}/api-reference`,
+ icon: Braces,
+ external: true,
+ },
+ {
+ name: "CLI",
+ href: `${DOCS}/reference/cli-reference`,
+ icon: Terminal,
+ external: true,
+ },
+ {
+ name: "MCP server",
+ href: `${DOCS}/reference/mcp-server`,
+ icon: ModelContextProtocolIcon,
+ external: true,
+ },
+ ],
+ },
+ {
+ label: "Workspace",
+ items: [
+ { name: "Audit logs", href: "/audit-logs", icon: ScanEye },
+ { name: "Team & invites", href: "/settings/general", icon: UserPlus },
+ ],
+ },
+];
+
+export function FeatureBadgeWall({
+ className,
+ ...props
+}: Omit<React.ComponentProps<"div">, "children">) {
+ return (
+ <div
+ className={cn("flex flex-col gap-3 md:min-h-0 md:flex-1", className)}
+ {...props}
+ >
+ <OnboardingResultHeading>
+ What else openstatus can do
+ </OnboardingResultHeading>
+ <div className="rounded-md border border-border bg-background p-4 md:min-h-0 md:flex-1 md:overflow-y-auto">
+ <div className="flex flex-col gap-4">
+ {FEATURE_CATEGORIES.map((category) => (
+ <section key={category.label} className="flex flex-col gap-2">
+ <p className="font-commit-mono text-muted-foreground text-xs uppercase tracking-wide">
+ {category.label}
+ </p>
+ <div className="flex flex-wrap gap-x-4 gap-y-1.5">
+ {category.items.map((item) => (
+ <FeatureLink key={item.name} item={item} />
+ ))}
+ </div>
+ </section>
+ ))}
+ </div>
+ </div>
+ </div>
+ );
+}
+
+export function QuestionPanel({
+ onSubmit,
+ className,
+ ...props
+}: Omit<React.ComponentProps<"div">, "children" | "onSubmit"> & {
+ onSubmit: (values: { source: string; other?: string }) => Promise<void>;
+}) {
+ return (
+ <div className={cn("flex flex-col gap-3", className)} {...props}>
+ <OnboardingResultHeading>
+ How did you hear about openstatus?
+ </OnboardingResultHeading>
+ <div className="rounded-md border border-border bg-background p-4">
+ <QuestionForm onSubmit={onSubmit} />
+ </div>
+ </div>
+ );
+}
+
+function FeatureLink({
+ item,
+ className,
+ ...props
+}: Omit<React.ComponentProps<typeof Link>, "href" | "children"> & {
+ item: FeatureLinkItem;
+}) {
+ const externalProps = item.external
+ ? { target: "_blank" as const, rel: "noopener noreferrer" }
+ : {};
+ return (
+ <Link
+ className={cn(
+ "group inline-flex items-center gap-1.5 font-commit-mono text-muted-foreground text-sm transition-colors hover:text-foreground",
+ className,
+ )}
+ href={item.href}
+ {...externalProps}
+ {...props}
+ >
+ <item.icon className="size-3" />
+ <span>{item.name}</span>
+ {item.external ? (
+ <ArrowUpRight className="size-3 text-muted-foreground/70 group-hover:text-foreground" />
+ ) : null}
+ </Link>
+ );
+}
diff --git a/apps/dashboard/src/components/onboarding/status-page-preview.tsx b/apps/dashboard/src/components/onboarding/status-page-preview.tsx
new file mode 100644
index 000000000..976994ded
--- /dev/null
+++ b/apps/dashboard/src/components/onboarding/status-page-preview.tsx
@@ -0,0 +1,211 @@
+"use client";
+
+// Canonical reference for the composition this mirrors:
+// apps/status-page/src/app/(status-page)/[domain]/[locale]/(public)/layout.tsx
+// apps/status-page/src/components/nav/header.tsx
+//
+// We intentionally do NOT extract a shared `<StatusPagePreview>` block — the
+// real status page wires next/link nav, the email-subscribe form, locale
+// switcher, password gate, status-fetcher, etc., and forcing those through
+// slot props would turn the shared block into a configuration soup. The
+// onboarding preview only needs visual chrome, so we compose the leaf blocks
+// directly. When a leaf-block API changes, both consumers feel it; if the
+// canonical composition reshuffles, update this file by hand against the
+// reference above.
+
+import { cn } from "@/lib/utils";
+import {
+ THEMES,
+ type ThemeKey,
+ type ThemeMode,
+ type ThemeVars,
+} from "@openstatus/theme-store";
+import { StatusBanner } from "@openstatus/ui/components/blocks/status-banner";
+import { StatusBar } from "@openstatus/ui/components/blocks/status-bar";
+import {
+ StatusComponent,
+ StatusComponentBody,
+ StatusComponentHeader,
+ StatusComponentHeaderLeft,
+ StatusComponentHeaderRight,
+ StatusComponentIcon,
+ StatusComponentTitle,
+ StatusComponentUptime,
+} from "@openstatus/ui/components/blocks/status-component";
+import { StatusFeed } from "@openstatus/ui/components/blocks/status-feed";
+import {
+ Status,
+ StatusContent,
+ StatusDescription,
+ StatusHeader,
+ StatusTitle,
+} from "@openstatus/ui/components/blocks/status-layout";
+import {
+ StatusPageHeader,
+ StatusPageHeaderActions,
+ StatusPageHeaderBrand,
+ StatusPageHeaderBrandFallback,
+ StatusPageHeaderContent,
+} from "@openstatus/ui/components/blocks/status-page-header";
+import {
+ StatusPageMain,
+ StatusPageShell,
+} from "@openstatus/ui/components/blocks/status-page-shell";
+import type { StatusBarData } from "@openstatus/ui/components/blocks/status.types";
+import { Separator } from "@openstatus/ui/components/ui/separator";
+import { Skeleton } from "@openstatus/ui/components/ui/skeleton";
+import { useTheme } from "next-themes";
+import { useEffect, useMemo, useRef, useState } from "react";
+
+// 45 days of all-green placeholder data so the bars render solid instead of
+// loading-skeleton on first paint. The user has no real history yet — this is
+// "what the page will look like once data flows in," matching what every demo
+// status page looks like the day it ships. Built per-mount (via useState
+// initializer below) so the window stays current across long-lived sessions.
+function buildPlaceholderBarData(): StatusBarData[] {
+ return Array.from({ length: 45 }, (_, i) => {
+ const day = new Date();
+ day.setDate(day.getDate() - (44 - i));
+ const iso = day.toISOString().slice(0, 10);
+ return {
+ day: iso,
+ bar: [{ status: "success", height: 100 }],
+ card: [{ status: "success", value: "100%" }],
+ events: [],
+ };
+ });
+}
+
+export type OnboardingStatusPagePreviewProps = {
+ slug: string;
+ title?: string;
+ description?: string;
+ components: { name: string }[];
+ monitorName?: string | null;
+ themeKey: ThemeKey;
+ className?: string;
+};
+
+export function OnboardingStatusPagePreview({
+ slug,
+ title,
+ description,
+ components,
+ monitorName,
+ themeKey,
+ className,
+}: OnboardingStatusPagePreviewProps) {
+ const { resolvedTheme } = useTheme();
+ const mode: ThemeMode = resolvedTheme === "dark" ? "dark" : "light";
+
+ // Single mount flag drives:
+ // 1. `useThemeVars` mode resolution (next-themes only resolves `system`
+ // client-side, so SSR uses light and we settle on mount).
+ // 2. `<StatusBar container>` — `previewRef.current` is null on the first
+ // render, so we wait until after mount before handing the ref to the
+ // Radix portal. Reading `mounted` in the JSX makes the dependency
+ // explicit instead of relying on a render side-effect.
+ const previewRef = useRef<HTMLDivElement | null>(null);
+ const [mounted, setMounted] = useState(false);
+ useEffect(() => setMounted(true), []);
+
+ const themeStyle = useThemeVars(themeKey, mode, mounted);
+ const [placeholderBarData] = useState(buildPlaceholderBarData);
+
+ const displayTitle = title?.trim() || slug || "My Status Page";
+ const allComponents: { key: string; name: string }[] = [
+ ...(monitorName ? [{ key: "__monitor", name: monitorName }] : []),
+ ...components
+ .filter((c) => c.name.trim().length > 0)
+ .map((c, i) => ({ key: `c-${i}`, name: c.name })),
+ ];
+
+ if (!mounted) {
+ return (
+ <Skeleton className={cn("rounded-md border border-border", className)} />
+ );
+ }
+
+ return (
+ <div
+ ref={previewRef}
+ data-status-preview
+ style={themeStyle}
+ className={cn(
+ "flex flex-col overflow-y-auto rounded-md border border-border bg-background text-foreground",
+ className,
+ )}
+ >
+ <StatusPageShell className="min-h-0 shrink-0">
+ <StatusPageHeader className="w-full border-border border-b">
+ <StatusPageHeaderContent>
+ <StatusPageHeaderBrand>
+ <div className="flex size-8 items-center justify-center overflow-hidden rounded-md border border-border bg-background">
+ <StatusPageHeaderBrandFallback title={displayTitle} />
+ </div>
+ </StatusPageHeaderBrand>
+ <StatusPageHeaderActions />
+ </StatusPageHeaderContent>
+ </StatusPageHeader>
+ <StatusPageMain>
+ <Status variant="success" className="gap-6">
+ <StatusHeader>
+ <StatusTitle>{displayTitle}</StatusTitle>
+ {description ? (
+ <StatusDescription>{description}</StatusDescription>
+ ) : null}
+ </StatusHeader>
+ <StatusBanner status="success" />
+ <StatusContent>
+ {allComponents.map((c) => (
+ <StatusComponent key={c.key} variant="success">
+ <StatusComponentHeader>
+ <StatusComponentHeaderLeft>
+ <StatusComponentTitle>{c.name}</StatusComponentTitle>
+ </StatusComponentHeaderLeft>
+ <StatusComponentHeaderRight>
+ <StatusComponentUptime>100%</StatusComponentUptime>
+ <StatusComponentIcon />
+ </StatusComponentHeaderRight>
+ </StatusComponentHeader>
+ <StatusComponentBody>
+ <StatusBar
+ data={placeholderBarData}
+ container={mounted ? previewRef.current : null}
+ />
+ </StatusComponentBody>
+ </StatusComponent>
+ ))}
+ </StatusContent>
+ <Separator />
+ <StatusContent>
+ <StatusFeed statusReports={[]} maintenances={[]} />
+ </StatusContent>
+ </Status>
+ </StatusPageMain>
+ </StatusPageShell>
+ </div>
+ );
+}
+
+// Inline `style` (not a `<style>` tag with `:root`) keeps the palette
+// contained to this subtree — the surrounding dashboard keeps its own theme.
+// `next-themes` resolves `system` only on the client, so SSR uses light and
+// the caller settles to the resolved mode after mount via the `mounted` flag.
+//
+// `--radius: 0rem` mirrors `apps/status-page/src/app/globals.css:21` — the
+// status-page app forces a flat baseline so square corners are the default
+// and only `OPENSTATUS_ROUNDED_THEME` (which sets its own `--radius`) goes
+// curved. Without this baseline, the preview inherits the dashboard's
+// `--radius: 0.625rem` and every theme renders rounded.
+function useThemeVars(themeKey: ThemeKey, mode: ThemeMode, mounted: boolean) {
+ return useMemo<React.CSSProperties>(() => {
+ const theme = THEMES[themeKey] ?? THEMES.default;
+ const vars: ThemeVars =
+ mounted && mode === "dark" ? theme.dark : theme.light;
+ return {
+ "--radius": "0rem",
+ ...vars,
+ } as React.CSSProperties;
+ }, [themeKey, mode, mounted]);
+}
diff --git a/apps/dashboard/src/components/onboarding/use-stream-checks.ts b/apps/dashboard/src/components/onboarding/use-stream-checks.ts
new file mode 100644
index 000000000..db3aee028
--- /dev/null
+++ b/apps/dashboard/src/components/onboarding/use-stream-checks.ts
@@ -0,0 +1,100 @@
+"use client";
+
+import type { CheckResult } from "@openstatus/services/monitor";
+import { useCallback, useEffect, useRef, useState } from "react";
+import { toast } from "sonner";
+
+export function useStreamChecks() {
+ const [results, setResults] = useState<CheckResult[]>([]);
+ const [isStreaming, setIsStreaming] = useState(false);
+ const [error, setError] = useState<string | null>(null);
+ const abortRef = useRef<AbortController | null>(null);
+
+ const fail = useCallback((message: string) => {
+ setError(message);
+ setIsStreaming(false);
+ toast.error(message);
+ }, []);
+
+ const stop = useCallback(() => {
+ abortRef.current?.abort();
+ abortRef.current = null;
+ setIsStreaming(false);
+ }, []);
+
+ const start = useCallback(
+ async (monitorId: number) => {
+ abortRef.current?.abort();
+ const controller = new AbortController();
+ abortRef.current = controller;
+ setResults([]);
+ setError(null);
+ setIsStreaming(true);
+
+ try {
+ const res = await fetch("/api/onboarding/checks", {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify({ monitorId }),
+ signal: controller.signal,
+ });
+
+ if (!res.ok || !res.body) {
+ const json = (await res.json().catch(() => null)) as {
+ error?: string;
+ } | null;
+ fail(json?.error ?? `Stream failed (${res.status})`);
+ return;
+ }
+
+ const reader = res.body.getReader();
+ const decoder = new TextDecoder();
+ let buffer = "";
+
+ while (true) {
+ const { value, done } = await reader.read();
+ if (done) break;
+ buffer += decoder.decode(value, { stream: true });
+ let nl = buffer.indexOf("\n");
+ while (nl !== -1) {
+ const line = buffer.slice(0, nl).trim();
+ buffer = buffer.slice(nl + 1);
+ if (line) {
+ try {
+ const parsed = JSON.parse(line) as CheckResult;
+ setResults((prev) => [...prev, parsed]);
+ } catch {
+ // ignore partial / malformed lines
+ }
+ }
+ nl = buffer.indexOf("\n");
+ }
+ }
+
+ if (buffer.trim()) {
+ try {
+ const parsed = JSON.parse(buffer.trim()) as CheckResult;
+ setResults((prev) => [...prev, parsed]);
+ } catch {
+ // ignore tail
+ }
+ }
+ } catch (err) {
+ if ((err as Error)?.name === "AbortError") return;
+ fail(err instanceof Error ? err.message : "Stream failed");
+ } finally {
+ setIsStreaming(false);
+ abortRef.current = null;
+ }
+ },
+ [fail],
+ );
+
+ useEffect(() => {
+ return () => {
+ abortRef.current?.abort();
+ };
+ }, []);
+
+ return { results, isStreaming, error, start, stop };
+}
diff --git a/apps/dashboard/src/components/ui/data-table/data-table-skeleton.tsx b/apps/dashboard/src/components/ui/data-table/data-table-skeleton.tsx
index 0ae5bf368..4edf01306 100644
--- a/apps/dashboard/src/components/ui/data-table/data-table-skeleton.tsx
+++ b/apps/dashboard/src/components/ui/data-table/data-table-skeleton.tsx
@@ -39,7 +39,7 @@ export function DataTableSkeleton({ rows = 3 }: DataTableSkeletonProps) {
</TableRow>
</TableHeader>
<TableBody>
- {[rows].fill(0).map((_, i) => (
+ {Array.from({ length: rows }).map((_, i) => (
<TableRow key={i} className="hover:bg-transparent">
<TableCell>
<Skeleton className="my-1.5 h-4 w-full max-w-40" />
diff --git a/apps/dashboard/src/data/onboarding-checks.ts b/apps/dashboard/src/data/onboarding-checks.ts
new file mode 100644
index 000000000..746d44b64
--- /dev/null
+++ b/apps/dashboard/src/data/onboarding-checks.ts
@@ -0,0 +1,103 @@
+import type { OnboardingChecksRow } from "@/components/onboarding/checks-table";
+
+const SAMPLE: Array<{ region: string; status: number; latency: number }> = [
+ { region: "ams", status: 200, latency: 44 },
+ { region: "fra", status: 200, latency: 84 },
+ { region: "arn", status: 200, latency: 167 },
+ { region: "iad", status: 200, latency: 44 },
+ { region: "sin", status: 200, latency: 32 },
+ { region: "ewr", status: 200, latency: 133 },
+ { region: "cdg", status: 200, latency: 219 },
+ { region: "ord", status: 200, latency: 118 },
+ { region: "sjc", status: 200, latency: 119 },
+ { region: "yyz", status: 200, latency: 104 },
+ { region: "lhr", status: 200, latency: 297 },
+ { region: "dfw", status: 200, latency: 132 },
+ { region: "lax", status: 200, latency: 128 },
+ { region: "nrt", status: 200, latency: 211 },
+ { region: "hkg", status: 200, latency: 198 },
+ { region: "syd", status: 200, latency: 254 },
+ { region: "bom", status: 200, latency: 276 },
+ { region: "gru", status: 200, latency: 187 },
+ { region: "scl", status: 200, latency: 232 },
+ { region: "jnb", status: 200, latency: 312 },
+ { region: "mad", status: 200, latency: 92 },
+ { region: "waw", status: 200, latency: 138 },
+ { region: "otp", status: 200, latency: 156 },
+ { region: "mia", status: 200, latency: 96 },
+ { region: "atl", status: 200, latency: 88 },
+ { region: "sea", status: 200, latency: 142 },
+ { region: "phx", status: 200, latency: 124 },
+ { region: "den", status: 200, latency: 113 },
+ { region: "yul", status: 200, latency: 98 },
+ { region: "gdl", status: 200, latency: 165 },
+ { region: "bog", status: 200, latency: 178 },
+ { region: "eze", status: 200, latency: 245 },
+];
+
+// Fixed seed timestamp keeps SSR/CSR HTML identical (no hydration mismatch).
+// Exact value is irrelevant — the placeholder sits behind a hint overlay.
+const now = new Date("2026-01-01T00:00:00.000Z").getTime();
+
+// Deterministic pseudo-random in [0, 1) seeded by string — keeps SSR/CSR stable.
+function seeded(seed: string) {
+ let h = 2166136261;
+ for (let i = 0; i < seed.length; i++) {
+ h ^= seed.charCodeAt(i);
+ h = Math.imul(h, 16777619);
+ }
+ return ((h >>> 0) % 10000) / 10000;
+}
+
+function jitter(seed: string, base: number, spread: number) {
+ return base + (seeded(seed) - 0.5) * 2 * spread;
+}
+
+function buildTiming(region: string, latency: number) {
+ const weights = {
+ dns: jitter(`${region}:dns`, 0.08, 0.04),
+ connect: jitter(`${region}:connect`, 0.14, 0.06),
+ tls: jitter(`${region}:tls`, 0.22, 0.08),
+ ttfb: jitter(`${region}:ttfb`, 0.45, 0.1),
+ transfer: jitter(`${region}:transfer`, 0.11, 0.05),
+ };
+ const total =
+ weights.dns +
+ weights.connect +
+ weights.tls +
+ weights.ttfb +
+ weights.transfer;
+ const dns = Math.max(1, Math.round((weights.dns / total) * latency));
+ const connect = Math.max(1, Math.round((weights.connect / total) * latency));
+ const tls = Math.max(1, Math.round((weights.tls / total) * latency));
+ const transfer = Math.max(
+ 1,
+ Math.round((weights.transfer / total) * latency),
+ );
+ const ttfb = Math.max(1, latency - dns - connect - tls - transfer);
+ return { dns, connect, tls, ttfb, transfer };
+}
+
+export const exampleChecks: OnboardingChecksRow[] = SAMPLE.map(
+ ({ region, status, latency }, i) =>
+ ({
+ type: "http",
+ id: region,
+ latency,
+ statusCode: status,
+ requestStatus: "success",
+ region,
+ timing: buildTiming(region, latency),
+ timestamp: now + i * 1000,
+ cronTimestamp: now + i * 1000,
+ trigger: "api",
+ monitorId: "0",
+ url: "",
+ error: false,
+ message: null,
+ headers: null,
+ body: null,
+ assertions: null,
+ workspaceId: "",
+ }) satisfies OnboardingChecksRow,
+);
diff --git a/apps/dashboard/src/lib/edge-context.ts b/apps/dashboard/src/lib/edge-context.ts
new file mode 100644
index 000000000..0a42b2036
--- /dev/null
+++ b/apps/dashboard/src/lib/edge-context.ts
@@ -0,0 +1,66 @@
+import { auth } from "@/lib/auth";
+import { asc, db, eq, schema } from "@openstatus/db";
+import type { ServiceContext } from "@openstatus/services";
+
+/**
+ * Build a `ServiceContext` from a Next.js Edge Route Handler request.
+ * Resolves session → user → workspace from the request, mirroring the
+ * shape that tRPC's `enforceUserIsAuthed` middleware produces.
+ *
+ * Returns `null` when the caller is unauthenticated or has no
+ * accessible workspace — route handlers should return 401/404 in that case.
+ */
+export async function getServiceContextFromRequest(
+ req: Request,
+): Promise<ServiceContext | null> {
+ const session = await auth();
+ if (!session?.user?.id) return null;
+
+ const userId = Number(session.user.id);
+ if (Number.isNaN(userId)) return null;
+
+ // `orderBy` on the join makes the no-cookie fallback below deterministic:
+ // `usersToWorkspaces[0]` is the user's earliest membership instead of
+ // whatever order Turso happens to return.
+ const userAndWorkspace = await db.query.user.findFirst({
+ where: eq(schema.user.id, userId),
+ with: {
+ usersToWorkspaces: {
+ orderBy: (t) => asc(t.createdAt),
+ with: {
+ workspace: true,
+ },
+ },
+ },
+ });
+
+ if (!userAndWorkspace) return null;
+
+ // Use slice rather than split("=")[1] so values containing "=" (e.g.
+ // base64-padded variants in other flows) survive intact.
+ const workspaceSlugCookie = (() => {
+ const raw = req.headers
+ .get("cookie")
+ ?.split(";")
+ .map((c) => c.trim())
+ .find((c) => c.startsWith("workspace-slug="));
+ return raw ? raw.slice(raw.indexOf("=") + 1) : undefined;
+ })();
+
+ // Fall back to first workspace when the cookie is stale (slug renamed,
+ // user removed) — matches `enforceUserIsAuthed` in tRPC.
+ const activeWorkspace = workspaceSlugCookie
+ ? userAndWorkspace.usersToWorkspaces?.find(
+ ({ workspace }) => workspace.slug === workspaceSlugCookie,
+ )?.workspace ?? userAndWorkspace.usersToWorkspaces?.[0]?.workspace
+ : userAndWorkspace.usersToWorkspaces?.[0]?.workspace;
+
+ if (!activeWorkspace) return null;
+
+ const workspace = schema.selectWorkspaceSchema.parse(activeWorkspace);
+
+ return {
+ workspace,
+ actor: { type: "user", userId },
+ };
+}
diff --git a/apps/dashboard/src/lib/onboarding/email-domain.ts b/apps/dashboard/src/lib/onboarding/email-domain.ts
new file mode 100644
index 000000000..102e264cb
--- /dev/null
+++ b/apps/dashboard/src/lib/onboarding/email-domain.ts
@@ -0,0 +1,31 @@
+const GENERIC_EMAIL_DOMAINS = new Set([
+ "gmail.com",
+ "yahoo.com",
+ "outlook.com",
+ "hotmail.com",
+ "icloud.com",
+ "protonmail.com",
+ "proton.me",
+ "aol.com",
+ "live.com",
+ "msn.com",
+ "yandex.com",
+ "mail.com",
+ "gmx.com",
+ "fastmail.com",
+ "me.com",
+ "duck.com",
+ "pm.me",
+ "tutanota.com",
+ "hey.com",
+ "zoho.com",
+ "ymail.com",
+]);
+
+export function getCompanyDomainFromEmail(
+ email: string | null | undefined,
+): string | null {
+ const domain = email?.split("@")[1]?.toLowerCase();
+ if (!domain || GENERIC_EMAIL_DOMAINS.has(domain)) return null;
+ return domain;
+}
diff --git a/apps/docs/src/content/docs/reference.mdx b/apps/docs/src/content/docs/reference.mdx
index 6800e8cbd..10ccfc0be 100644
--- a/apps/docs/src/content/docs/reference.mdx
+++ b/apps/docs/src/content/docs/reference.mdx
@@ -45,10 +45,15 @@ Detailed specifications for each monitor type:
<LinkCard title="Private Location" href="/reference/private-location" description="Self-hosted monitoring agent reference" />
</CardGrid>
-### API Documentation
+### Programmatic Access
-For programmatic access to openstatus:
-- **[REST API](https://api.openstatus.dev/v1)** - Full REST API reference with interactive examples
+Manage openstatus from your own scripts, infrastructure, or AI assistants:
+
+<CardGrid>
+ <LinkCard title="REST API" href="https://api.openstatus.dev/openapi" description="Full REST API reference with interactive examples" />
+ <LinkCard title="CLI" href="/reference/cli-reference" description="Manage monitors and pages from the command line" />
+ <LinkCard title="MCP Server" href="/reference/mcp-server" description="Connect Claude, Cursor, and other AI assistants via Model Context Protocol" />
+</CardGrid>
### Related sections
diff --git a/apps/web/next-env.d.ts b/apps/web/next-env.d.ts
index c4b7818fb..9edff1c7c 100644
--- a/apps/web/next-env.d.ts
+++ b/apps/web/next-env.d.ts
@@ -1,6 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
-import "./.next/dev/types/routes.d.ts";
+import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/apps/web/src/lib/stream.ts b/apps/web/src/lib/stream.ts
index bbbd9ee00..b121ce76c 100644
--- a/apps/web/src/lib/stream.ts
+++ b/apps/web/src/lib/stream.ts
@@ -1,77 +1 @@
-export async function* yieldMany(promises: Promise<unknown>[]) {
- // Attach .then() handlers to the promises to remove them as soon as they resolve
- // biome-ignore lint/complexity/noForEach: REMINDER: do not use for await (const p of promises) as it will not work as expected
- promises.forEach((p) => {
- p.then((value) => {
- promises.splice(promises.indexOf(p), 1);
- return value;
- });
- });
-
- // Continue yielding the results of the promises as they resolve
- while (promises.length > 0) {
- yield await Promise.race(promises);
- }
-
- return "done";
-}
-
-export function iteratorToStream(iterator: AsyncGenerator) {
- return new ReadableStream({
- async pull(controller) {
- try {
- const { value, done } = await iterator.next();
- if (done) {
- controller.close();
- } else {
- controller.enqueue(value);
- }
- } catch (err) {
- console.error("Stream error:", err);
- controller.error(err);
- }
- },
- });
-}
-
-const encoder = new TextEncoder();
-const decoder = new TextDecoder();
-
-/**
- * HOW TO USE IT IN YOUR ROUTE
- * @returns {Response}
- */
-export async function POST(request: Request) {
- // extract your params from the request
- const _json = await request.json();
-
- const generator = yieldMany([
- new Promise((resolve) =>
- setTimeout(() => resolve(encoder.encode("1")), 200),
- ),
- new Promise((resolve) => resolve(encoder.encode("2"))),
- new Promise((resolve) =>
- setTimeout(() => resolve(encoder.encode("3")), 500),
- ),
- ]);
-
- const stream = iteratorToStream(generator);
- return new Response(stream);
-}
-
-/**
- * HOW TO USE IT IN YOUR CLIENT
- */
-async function clientConsumeStream() {
- const response = await POST(new Request("")); // fetch("/api/path/to/route", { method: "POST" });
- const reader = response.body?.getReader();
- if (!reader) return;
-
- while (true) {
- const { value, done } = await reader.read();
- if (done) break;
- console.log("Stream output:", decoder.decode(value));
- }
-
- console.log("Stream processing complete.");
-}
+export { yieldMany, iteratorToStream } from "@openstatus/utils";
diff --git a/packages/db/src/schema/feedbacks/constants.ts b/packages/db/src/schema/feedbacks/constants.ts
index adbf99f2d..12e5d0388 100644
--- a/packages/db/src/schema/feedbacks/constants.ts
+++ b/packages/db/src/schema/feedbacks/constants.ts
@@ -3,6 +3,7 @@ export const feedbackSource = [
"widget",
"onboarding-intent",
"onboarding-source",
+ "onboarding-completed",
] as const;
export const feedbackType = [
diff --git a/packages/icons/src/bluesky.tsx b/packages/icons/src/bluesky.tsx
new file mode 100644
index 000000000..d8885ea55
--- /dev/null
+++ b/packages/icons/src/bluesky.tsx
@@ -0,0 +1,15 @@
+export function BlueskyIcon(props: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ role="img"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ stroke="currentColor"
+ fill="currentColor"
+ {...props}
+ >
+ <title>Bluesky</title>
+ <path d="M12 10.8c-1.087-2.114-4.046-6.053-6.798-7.995C2.566.944 1.561 1.266.902 1.565.139 1.908 0 3.08 0 3.768c0 .69.378 5.65.624 6.479.815 2.736 3.713 3.66 6.383 3.364.136-.02.275-.039.415-.056-.138.022-.276.04-.415.056-3.912.58-7.387 2.005-2.83 7.078 5.013 5.19 6.87-1.113 7.823-4.308.953 3.195 2.05 9.271 7.733 4.308 4.267-4.308 1.172-6.498-2.74-7.078a8.741 8.741 0 0 1-.415-.056c.14.017.279.036.415.056 2.67.297 5.568-.628 6.383-3.364.246-.828.624-5.79.624-6.478 0-.69-.139-1.861-.902-2.206-.659-.298-1.664-.62-4.3 1.24C16.046 4.748 13.087 8.687 12 10.8Z" />
+ </svg>
+ );
+}
diff --git a/packages/icons/src/index.tsx b/packages/icons/src/index.tsx
index c5a18b61a..c23fa28a9 100644
--- a/packages/icons/src/index.tsx
+++ b/packages/icons/src/index.tsx
@@ -15,3 +15,7 @@ export * from "./statuspage";
export * from "./betterstack";
export * from "./instatus";
export * from "./modelcontextprotocol";
+export * from "./x";
+export * from "./linkedin";
+export * from "./bluesky";
+export * from "./youtube";
diff --git a/packages/icons/src/linkedin.tsx b/packages/icons/src/linkedin.tsx
new file mode 100644
index 000000000..02d561630
--- /dev/null
+++ b/packages/icons/src/linkedin.tsx
@@ -0,0 +1,15 @@
+export function LinkedInIcon(props: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ role="img"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ stroke="currentColor"
+ fill="currentColor"
+ {...props}
+ >
+ <title>LinkedIn</title>
+ <path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.062 2.062 0 01-2.063-2.065 2.063 2.063 0 112.063 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z" />
+ </svg>
+ );
+}
diff --git a/packages/icons/src/x.tsx b/packages/icons/src/x.tsx
new file mode 100644
index 000000000..a300ef3cf
--- /dev/null
+++ b/packages/icons/src/x.tsx
@@ -0,0 +1,15 @@
+export function XIcon(props: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ role="img"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ stroke="currentColor"
+ fill="currentColor"
+ {...props}
+ >
+ <title>X</title>
+ <path d="M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z" />
+ </svg>
+ );
+}
diff --git a/packages/icons/src/youtube.tsx b/packages/icons/src/youtube.tsx
new file mode 100644
index 000000000..13214b593
--- /dev/null
+++ b/packages/icons/src/youtube.tsx
@@ -0,0 +1,15 @@
+export function YouTubeIcon(props: React.ComponentProps<"svg">) {
+ return (
+ <svg
+ role="img"
+ viewBox="0 0 24 24"
+ xmlns="http://www.w3.org/2000/svg"
+ stroke="currentColor"
+ fill="currentColor"
+ {...props}
+ >
+ <title>YouTube</title>
+ <path d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z" />
+ </svg>
+ );
+}
diff --git a/packages/services/src/monitor/__tests__/stream-monitor-preview.test.ts b/packages/services/src/monitor/__tests__/stream-monitor-preview.test.ts
new file mode 100644
index 000000000..16a810c9d
--- /dev/null
+++ b/packages/services/src/monitor/__tests__/stream-monitor-preview.test.ts
@@ -0,0 +1,106 @@
+import { afterAll, beforeAll, describe, expect, test } from "bun:test";
+
+import { SEEDED_WORKSPACE_FREE_ID } from "../../../test/fixtures";
+import {
+ loadSeededWorkspace,
+ makeUserCtx,
+ withTestTransaction,
+} from "../../../test/helpers";
+import { NotFoundError } from "../../errors";
+import { createMonitor } from "../create";
+import { streamMonitorPreview } from "../stream-monitor-preview";
+
+const originalFetch = globalThis.fetch;
+const originalCronSecret = process.env.CRON_SECRET;
+
+describe("streamMonitorPreview", () => {
+ beforeAll(() => {
+ process.env.CRON_SECRET = "test-cron-secret";
+ // Stub the Go-checker fetch to a fast in-memory response so the test
+ // doesn't hit the real network. Each call returns a minimal success
+ // payload that the service generator parses into a CheckResult.
+ globalThis.fetch = (async () => {
+ return new Response(
+ JSON.stringify({
+ state: "success",
+ status: 200,
+ latency: 100,
+ timestamp: Date.now(),
+ timing: {
+ dnsStart: 0,
+ dnsDone: 10,
+ connectStart: 10,
+ connectDone: 20,
+ tlsHandshakeStart: 20,
+ tlsHandshakeDone: 40,
+ firstByteStart: 40,
+ firstByteDone: 90,
+ transferStart: 90,
+ transferDone: 100,
+ },
+ headers: { "x-test": "1" },
+ body: "ok",
+ }),
+ { headers: { "Content-Type": "application/json" } },
+ );
+ }) as unknown as typeof fetch;
+ });
+
+ afterAll(() => {
+ globalThis.fetch = originalFetch;
+ if (originalCronSecret === undefined) {
+ process.env.CRON_SECRET = undefined;
+ } else {
+ process.env.CRON_SECRET = originalCronSecret;
+ }
+ });
+
+ test("throws NotFoundError when monitor belongs to a different workspace", async () => {
+ await withTestTransaction(async (tx) => {
+ const ws = await loadSeededWorkspace(SEEDED_WORKSPACE_FREE_ID);
+ const ctx = { ...makeUserCtx(ws), db: tx };
+
+ // Use a monitor id that does not exist for this workspace.
+ const generator = streamMonitorPreview({
+ ctx,
+ input: { monitorId: 999_999_999 },
+ });
+
+ await expect(async () => {
+ for await (const _ of generator) {
+ // drain
+ }
+ }).toThrow(NotFoundError);
+ });
+ });
+
+ test("yields one result per region for an owned monitor", async () => {
+ await withTestTransaction(async (tx) => {
+ const ws = await loadSeededWorkspace(SEEDED_WORKSPACE_FREE_ID);
+ const ctx = { ...makeUserCtx(ws), db: tx };
+ const created = await createMonitor({
+ ctx,
+ input: {
+ name: "preview-test",
+ jobType: "http",
+ url: "https://example.com",
+ method: "GET",
+ headers: [],
+ assertions: [],
+ active: true,
+ },
+ });
+
+ const results: { region: string }[] = [];
+ for await (const result of streamMonitorPreview({
+ ctx,
+ input: { monitorId: created.id },
+ })) {
+ results.push({ region: result.region });
+ }
+
+ // Should fan out across all available regions
+ expect(results.length).toBeGreaterThan(0);
+ });
+ });
+});
diff --git a/packages/services/src/monitor/index.ts b/packages/services/src/monitor/index.ts
index b507890e4..1c03a79cf 100644
--- a/packages/services/src/monitor/index.ts
+++ b/packages/services/src/monitor/index.ts
@@ -13,6 +13,13 @@ export {
updateMonitorSchedulingRegions,
updateMonitorTags,
} from "./relations";
+export {
+ type CheckResult,
+ type CheckResultError,
+ type CheckResultSuccess,
+ StreamMonitorPreviewInput,
+ streamMonitorPreview,
+} from "./stream-monitor-preview";
export {
bulkUpdateMonitors,
updateMonitorFollowRedirects,
diff --git a/packages/services/src/monitor/stream-monitor-preview.ts b/packages/services/src/monitor/stream-monitor-preview.ts
new file mode 100644
index 000000000..5338397d7
--- /dev/null
+++ b/packages/services/src/monitor/stream-monitor-preview.ts
@@ -0,0 +1,221 @@
+import { ALL_REGIONS, type Region, regionDict } from "@openstatus/regions";
+import { yieldMany } from "@openstatus/utils";
+import { z } from "zod";
+
+import { type ServiceContext, getReadDb } from "../context";
+import { InternalServiceError } from "../errors";
+import { getMonitorInWorkspace } from "./internal";
+
+export const StreamMonitorPreviewInput = z.object({
+ monitorId: z.number(),
+});
+
+export type StreamMonitorPreviewInput = z.infer<
+ typeof StreamMonitorPreviewInput
+>;
+
+const FLY_CHECKER_URL = "https://openstatus-checker.fly.dev/ping";
+const KOYEB_CHECKER_URL = "https://openstatus-checker.koyeb.app/ping";
+const RAILWAY_CHECKER_URL =
+ "https://railway-proxy-production-9cb1.up.railway.app/ping";
+
+const REGION_TIMEOUT_MS = 10_000;
+
+export type CheckResultSuccess = {
+ state: "success";
+ type: "http";
+ region: Region;
+ status: number;
+ latency: number;
+ timestamp: number;
+ timing: {
+ dnsStart: number;
+ dnsDone: number;
+ connectStart: number;
+ connectDone: number;
+ tlsHandshakeStart: number;
+ tlsHandshakeDone: number;
+ firstByteStart: number;
+ firstByteDone: number;
+ transferStart: number;
+ transferDone: number;
+ };
+ headers?: Record<string, string>;
+ body?: string | null;
+};
+
+export type CheckResultError = {
+ state: "error";
+ type: "http";
+ region: Region;
+ message: string;
+ timestamp: number;
+};
+
+export type CheckResult = CheckResultSuccess | CheckResultError;
+
+function getCheckerEndpoint(region: Region): {
+ endpoint: string;
+ regionHeader: Record<string, string>;
+} {
+ const provider = regionDict[region]?.provider ?? "fly";
+ switch (provider) {
+ case "fly":
+ return {
+ endpoint: `${FLY_CHECKER_URL}/${region}`,
+ regionHeader: { "fly-prefer-region": region },
+ };
+ case "koyeb":
+ return {
+ endpoint: `${KOYEB_CHECKER_URL}/${region}`,
+ regionHeader: {
+ "X-KOYEB-REGION-OVERRIDE": region.replace("koyeb_", ""),
+ },
+ };
+ case "railway":
+ return {
+ endpoint: `${RAILWAY_CHECKER_URL}/${region}`,
+ regionHeader: { "railway-region": region.replace("railway_", "") },
+ };
+ default:
+ return {
+ endpoint: `${FLY_CHECKER_URL}/${region}`,
+ regionHeader: {},
+ };
+ }
+}
+
+async function probeRegion(args: {
+ region: Region;
+ url: string;
+ method: string;
+ headers: Record<string, string> | undefined;
+ body: string | undefined;
+ cronSecret: string | undefined;
+}): Promise<CheckResult> {
+ const { region, url, method, headers, body, cronSecret } = args;
+ const { endpoint, regionHeader } = getCheckerEndpoint(region);
+
+ try {
+ const res = await fetch(endpoint, {
+ method: "POST",
+ headers: {
+ ...(cronSecret ? { Authorization: `Basic ${cronSecret}` } : {}),
+ "Content-Type": "application/json",
+ ...regionHeader,
+ },
+ body: JSON.stringify({
+ url,
+ method,
+ headers,
+ body,
+ }),
+ signal: AbortSignal.timeout(REGION_TIMEOUT_MS),
+ });
+
+ const json = (await res.json()) as Record<string, unknown>;
+
+ if (json && typeof json === "object" && json.state === "error") {
+ return {
+ state: "error",
+ type: "http",
+ region,
+ message: typeof json.message === "string" ? json.message : "Failed",
+ timestamp: Date.now(),
+ };
+ }
+ return {
+ state: "success",
+ type: "http",
+ region,
+ status: typeof json.status === "number" ? json.status : 0,
+ latency: typeof json.latency === "number" ? json.latency : 0,
+ timestamp:
+ typeof json.timestamp === "number" ? json.timestamp : Date.now(),
+ timing: (json.timing as CheckResultSuccess["timing"]) ?? {
+ dnsStart: 0,
+ dnsDone: 0,
+ connectStart: 0,
+ connectDone: 0,
+ tlsHandshakeStart: 0,
+ tlsHandshakeDone: 0,
+ firstByteStart: 0,
+ firstByteDone: 0,
+ transferStart: 0,
+ transferDone: 0,
+ },
+ headers: (json.headers as Record<string, string>) ?? undefined,
+ body: typeof json.body === "string" ? json.body : null,
+ };
+ } catch (err) {
+ return {
+ state: "error",
+ type: "http",
+ region,
+ message: err instanceof Error ? err.message : "Network error",
+ timestamp: Date.now(),
+ };
+ }
+}
+
+/**
+ * Streaming async generator — yields per-region preview results as they arrive.
+ * Probes ALL 28 regions, regardless of `monitor.regions` (plan-bounded).
+ * Does NOT persist to Tinybird. Ephemeral, onboarding-only.
+ */
+export async function* streamMonitorPreview(args: {
+ ctx: ServiceContext;
+ input: StreamMonitorPreviewInput;
+}): AsyncGenerator<CheckResult> {
+ const { ctx } = args;
+ const input = StreamMonitorPreviewInput.parse(args.input);
+
+ const tx = getReadDb(ctx);
+ const monitor = await getMonitorInWorkspace({
+ tx,
+ id: input.monitorId,
+ workspaceId: ctx.workspace.id,
+ });
+
+ const headers = monitor.headers
+ ? (() => {
+ try {
+ const parsed = JSON.parse(monitor.headers as string) as Array<{
+ key: string;
+ value: string;
+ }>;
+ return parsed.reduce<Record<string, string>>((acc, h) => {
+ if (h.key) acc[h.key] = h.value;
+ return acc;
+ }, {});
+ } catch {
+ return undefined;
+ }
+ })()
+ : undefined;
+
+ const cronSecret = process.env.CRON_SECRET;
+ if (!cronSecret) {
+ throw new InternalServiceError("CRON_SECRET is not set");
+ }
+
+ // Skip deprecated regions — fly (and other providers) no longer run
+ // machines there, so probes time out and produce noise rows. Mirrors
+ // the existing `pickDefaultRegions` filter in `internal.ts`.
+ const activeRegions = ALL_REGIONS.filter(
+ (region) => !regionDict[region].deprecated,
+ );
+
+ const promises: Promise<CheckResult>[] = activeRegions.map((region) =>
+ probeRegion({
+ region: region as Region,
+ url: monitor.url,
+ method: monitor.method ?? "GET",
+ headers,
+ body: monitor.body ?? undefined,
+ cronSecret,
+ }),
+ );
+
+ yield* yieldMany(promises);
+}
diff --git a/packages/ui/src/components/blocks/status-bar.tsx b/packages/ui/src/components/blocks/status-bar.tsx
index 2dc26d466..7347bb33c 100644
--- a/packages/ui/src/components/blocks/status-bar.tsx
+++ b/packages/ui/src/components/blocks/status-bar.tsx
@@ -33,6 +33,13 @@ interface StatusBarProps {
data: StatusBarData["events"][number],
index: number,
) => React.ReactNode;
+ /**
+ * Optional Radix Portal container for the day hover-card. Defaults to
+ * `document.body`. Pass a ref when the bar is rendered inside a scoped
+ * subtree (e.g. a status-page preview that overrides `--radius` and other
+ * CSS vars on a wrapper) so the portaled card inherits the same context.
+ */
+ container?: HTMLElement | null;
}
interface UseStatusBarProps {
@@ -424,6 +431,7 @@ export function StatusBar({
renderCard,
renderBar,
renderEvent,
+ container,
}: StatusBarProps) {
const labels = useStatusBlocksLabels();
const isTouch = useMediaQuery("(hover: none)");
@@ -459,6 +467,7 @@ export function StatusBar({
renderCard={renderCard}
renderBar={renderBar}
renderEvent={renderEvent}
+ container={container}
/>
);
})}
@@ -478,6 +487,7 @@ interface StatusBarItemProps {
renderCard?: StatusBarProps["renderCard"];
renderBar?: StatusBarProps["renderBar"];
renderEvent?: StatusBarProps["renderEvent"];
+ container?: StatusBarProps["container"];
}
const StatusBarItem = forwardRef<HTMLDivElement, StatusBarItemProps>(
@@ -493,6 +503,7 @@ const StatusBarItem = forwardRef<HTMLDivElement, StatusBarItemProps>(
renderCard,
renderBar,
renderEvent,
+ container,
},
ref,
) => {
@@ -543,6 +554,7 @@ const StatusBarItem = forwardRef<HTMLDivElement, StatusBarItemProps>(
side="top"
align="center"
className="w-auto min-w-40 p-0"
+ container={container}
onMouseEnter={handlers.onHoverCardEnter}
onMouseLeave={handlers.onHoverCardLeave}
onPointerDownOutside={(e) => {
diff --git a/packages/ui/src/components/ui/hover-card.tsx b/packages/ui/src/components/ui/hover-card.tsx
index 4ef4308c6..a9e1d7df7 100644
--- a/packages/ui/src/components/ui/hover-card.tsx
+++ b/packages/ui/src/components/ui/hover-card.tsx
@@ -23,10 +23,22 @@ function HoverCardContent({
className,
align = "center",
sideOffset = 4,
+ container,
...props
-}: React.ComponentProps<typeof HoverCardPrimitive.Content>) {
+}: React.ComponentProps<typeof HoverCardPrimitive.Content> & {
+ /**
+ * Optional Radix Portal container. Defaults to `document.body`. Pass an
+ * element ref when the hover-card needs to render inside a scoped subtree
+ * (e.g. a status-page preview that overrides `--radius` and other CSS vars
+ * on a wrapper) so portaled content inherits the same context.
+ */
+ container?: React.ComponentProps<typeof HoverCardPrimitive.Portal>["container"];
+}) {
return (
- <HoverCardPrimitive.Portal data-slot="hover-card-portal">
+ <HoverCardPrimitive.Portal
+ data-slot="hover-card-portal"
+ container={container}
+ >
<HoverCardPrimitive.Content
data-slot="hover-card-content"
align={align}
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index e887dea05..381c101d3 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -12,6 +12,7 @@ export {
MONITOR_STATUSES,
MONITOR_JOB_TYPES,
} from "./constants";
+export { yieldMany, iteratorToStream } from "./stream";
export function transformHeaders(headers: { key: string; value: string }[]) {
return headers.length > 0
diff --git a/packages/utils/src/stream.ts b/packages/utils/src/stream.ts
new file mode 100644
index 000000000..2de4e97cd
--- /dev/null
+++ b/packages/utils/src/stream.ts
@@ -0,0 +1,71 @@
+export async function* yieldMany<T>(promises: Promise<T>[]) {
+ // Race-free settle-as-they-arrive: each promise pushes into a queue when it
+ // resolves; the consumer drains the queue and parks on a fresh wake-up
+ // promise when empty. This avoids the splice/Promise.race pattern, which
+ // can drop values when multiple promises settle in the same microtask
+ // batch (both spliced before the next race iteration). Rejections are
+ // surfaced as thrown values to the caller — the underlying probe paths
+ // are expected to convert failures into result objects upstream.
+ const queue: T[] = [];
+ let pending = promises.length;
+ let wake: (() => void) | null = null;
+ let rejection: { error: unknown } | null = null;
+
+ for (const p of promises) {
+ p.then(
+ (value) => {
+ queue.push(value);
+ pending--;
+ wake?.();
+ },
+ (error) => {
+ // First rejection wins. Subsequent rejections in the same microtask
+ // batch must not silently overwrite — the consumer throws on the
+ // first one and any later ones would be lost. Probes are expected
+ // to convert per-region failures into result objects upstream, so
+ // landing here at all is exceptional.
+ if (!rejection) rejection = { error };
+ pending--;
+ wake?.();
+ },
+ );
+ }
+
+ while (pending > 0 || queue.length > 0) {
+ if (queue.length === 0 && rejection === null) {
+ await new Promise<void>((resolve) => {
+ wake = resolve;
+ });
+ wake = null;
+ }
+ while (queue.length > 0) {
+ // biome-ignore lint/style/noNonNullAssertion: length-guarded above
+ yield queue.shift()!;
+ }
+ if (rejection) {
+ const { error } = rejection;
+ rejection = null;
+ throw error;
+ }
+ }
+
+ return "done";
+}
+
+export function iteratorToStream(iterator: AsyncGenerator) {
+ return new ReadableStream({
+ async pull(controller) {
+ try {
+ const { value, done } = await iterator.next();
+ if (done) {
+ controller.close();
+ } else {
+ controller.enqueue(value);
+ }
+ } catch (err) {
+ console.error("Stream error:", err);
+ controller.error(err);
+ }
+ },
+ });
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 387b0651b..328111433 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -143,6 +143,9 @@ importers:
'@openstatus/regions':
specifier: workspace:*
version: link:../../packages/regions
+ '@openstatus/services':
+ specifier: workspace:*
+ version: link:../../packages/services
'@openstatus/subscriptions':
specifier: workspace:*
version: link:../../packages/subscriptions