Skip to content

Open source alternative to Semrush and Ahrefs

Show the full sidebar and page placeholders while the app loads (EVE-373) (#785)

Ben Senescu3b42767db3bd
diff --git a/src/client/components/QueryState.tsx b/src/client/components/QueryState.tsx
index 80dc2643..ed8818f0 100644
--- a/src/client/components/QueryState.tsx
+++ b/src/client/components/QueryState.tsx
@@ -8,7 +8,7 @@ import {
import { BILLING_ROUTE } from "@/shared/billing";
import { ErrorState } from "@/client/components/ErrorState";
import { Button } from "@/client/components/ui/button";
-import { PageLoading } from "./Spinner";
+import { SkeletonCard } from "./SkeletonPresets";
/**
* A load failure with a retry button. The message goes through
@@ -65,7 +65,7 @@ export function QueryError({
export function QueryState<TData>({
query,
errorFallback,
- loading = <PageLoading />,
+ loading = <SkeletonCard />,
children,
}: {
query: UseQueryResult<TData>;
diff --git a/src/client/components/Sidebar.tsx b/src/client/components/Sidebar.tsx
index 8fd3b039..e6c3224a 100644
--- a/src/client/components/Sidebar.tsx
+++ b/src/client/components/Sidebar.tsx
@@ -21,7 +21,10 @@ import {
getProjectNavGroups,
} from "@/client/navigation/items";
import { ProjectSwitcher } from "@/client/features/projects/ProjectSwitcher";
-import { SamSidebarPanel } from "@/client/features/sam/SamSidebarPanel";
+import {
+ SamChatListSkeleton,
+ SamSidebarPanel,
+} from "@/client/features/sam/SamSidebarPanel";
import { ThemePreferenceRadio } from "@/client/components/ThemePreferenceMenuItems";
import { getStandardErrorMessage } from "@/client/lib/error-messages";
import { signOutAndRedirect, useSession } from "@/lib/auth-client";
@@ -37,6 +40,7 @@ import {
SidebarMenu,
SidebarMenuButton,
SidebarMenuItem,
+ SidebarMenuSkeleton,
useSidebar,
} from "@/client/components/ui/sidebar";
import { Tabs, TabsList, TabsTrigger } from "@/client/components/ui/tabs";
@@ -57,42 +61,66 @@ function SidebarNavLink({
icon: Icon,
label,
linkProps,
+ placeholder = false,
}: {
icon: ComponentType<{ className?: string }>;
label: string;
linkProps: LinkOptions;
+ /** Show the row without its link, while its project is still unknown. */
+ placeholder?: boolean;
}) {
const { setOpenMobile } = useSidebar();
+ const row = (isActive: boolean) => (
+ <SidebarMenuButton
+ render={<span />}
+ isActive={isActive}
+ aria-disabled={placeholder || undefined}
+ className={navButtonClass}
+ >
+ <Icon className="size-4" />
+ <span>{label}</span>
+ </SidebarMenuButton>
+ );
return (
<SidebarMenuItem>
- <Link
- {...linkProps}
- activeOptions={{
- exact: false,
- includeSearch: false,
- ...linkProps.activeOptions,
- }}
- onClick={() => setOpenMobile(false)}
- >
- {({ isActive }) => (
- <SidebarMenuButton
- render={<span />}
- isActive={isActive}
- className={navButtonClass}
- >
- <Icon className="size-4" />
- <span>{label}</span>
- </SidebarMenuButton>
- )}
- </Link>
+ {placeholder ? (
+ row(false)
+ ) : (
+ <Link
+ {...linkProps}
+ activeOptions={{
+ exact: false,
+ includeSearch: false,
+ ...linkProps.activeOptions,
+ }}
+ onClick={() => setOpenMobile(false)}
+ >
+ {({ isActive }) => row(isActive)}
+ </Link>
+ )}
</SidebarMenuItem>
);
}
-export function Sidebar({ projectId }: { projectId: string | null }) {
- const navGroups = projectId
- ? getProjectNavGroups(projectId)
- : [connectNavGroup];
+export function Sidebar({
+ projectId,
+ projectPending,
+ ready,
+}: {
+ projectId: string | null;
+ /** No project is known yet, but the projects list may still name one. */
+ projectPending: boolean;
+ /** The session is confirmed, so the sidebar's own data can load. */
+ ready: boolean;
+}) {
+ // Until a project is known, show the project nav as rows without links, so
+ // the sidebar has its full shape from the first paint instead of growing
+ // once projects load. The placeholder rows never render these links.
+ const navPlaceholder = projectId === null && projectPending;
+ const navGroups =
+ projectId !== null || navPlaceholder
+ ? getProjectNavGroups(projectId ?? "")
+ : [connectNavGroup];
const navigate = useNavigate();
const { pathname } = useLocation();
const { setOpenMobile } = useSidebar();
@@ -138,12 +166,14 @@ export function Sidebar({ projectId }: { projectId: string | null }) {
</Link>
<ProjectSwitcher
activeProjectId={projectId}
+ ready={ready}
onCloseDrawer={() => setOpenMobile(false)}
/>
- {projectId ? (
+ {projectId !== null || navPlaceholder ? (
<Tabs
value={view}
onValueChange={(value) => {
+ if (projectId === null) return;
if (value === "chat") openChat(projectId);
else openBrowse(projectId);
}}
@@ -165,12 +195,21 @@ export function Sidebar({ projectId }: { projectId: string | null }) {
<SidebarContent>
{view === "chat" && projectId ? (
- <SamSidebarPanel
- projectId={projectId}
- onNavigate={() => setOpenMobile(false)}
- />
+ ready ? (
+ <SamSidebarPanel
+ projectId={projectId}
+ onNavigate={() => setOpenMobile(false)}
+ />
+ ) : (
+ <div className="px-2 py-1">
+ <SamChatListSkeleton />
+ </div>
+ )
) : (
- <nav aria-label="Main navigation">
+ <nav
+ aria-label="Main navigation"
+ aria-busy={navPlaceholder || undefined}
+ >
{navGroups.map((group) => (
<SidebarGroup key={group.label} className="py-1">
<SidebarGroupLabel className="h-7 uppercase tracking-wider text-sidebar-foreground/40">
@@ -186,6 +225,7 @@ export function Sidebar({ projectId }: { projectId: string | null }) {
icon={icon}
label={label}
linkProps={linkProps}
+ placeholder={navPlaceholder}
/>
);
})}
@@ -196,12 +236,12 @@ export function Sidebar({ projectId }: { projectId: string | null }) {
</nav>
)}
</SidebarContent>
- <AccountFooter />
+ <AccountFooter ready={ready} />
</UiSidebar>
);
}
-function AccountFooter() {
+function AccountFooter({ ready }: { ready: boolean }) {
const { data: session } = useSession();
const { setOpenMobile } = useSidebar();
const email = session?.user?.email;
@@ -316,12 +356,17 @@ function AccountFooter() {
</DropdownMenuContent>
</DropdownMenu>
</SidebarMenuItem>
- ) : (
+ ) : ready ? (
<SidebarNavLink
icon={Settings}
label="Settings"
linkProps={{ to: "/settings" }}
/>
+ ) : (
+ // The account row's slot while the session loads.
+ <SidebarMenuItem>
+ <SidebarMenuSkeleton showIcon />
+ </SidebarMenuItem>
)}
</SidebarMenu>
</UiSidebarFooter>
diff --git a/src/client/components/SkeletonPresets.tsx b/src/client/components/SkeletonPresets.tsx
index 534a0a23..62d816cc 100644
--- a/src/client/components/SkeletonPresets.tsx
+++ b/src/client/components/SkeletonPresets.tsx
@@ -1,4 +1,5 @@
import { cn } from "cn";
+import { Card, CardContent } from "@/client/components/ui/card";
import { Skeleton } from "@/client/components/ui/skeleton";
// Loading layouts built from the shadcn Skeleton primitive.
@@ -60,3 +61,37 @@ export function SkeletonTableRows({
</div>
);
}
+
+/** A card of table rows, for a section whose data has not arrived. */
+export function SkeletonCard({ className }: { className?: string }) {
+ return (
+ <Card className={className} aria-busy>
+ <CardContent>
+ <SkeletonTableRows rows={6} columns={4} />
+ </CardContent>
+ </Card>
+ );
+}
+
+/**
+ * A whole page whose data has not arrived: the standard page frame with a
+ * header and one card, so the real page replaces it without a jump.
+ */
+export function SkeletonPage() {
+ return (
+ <div className="px-4 py-4 pb-24 md:px-6 md:py-6 md:pb-8" aria-busy>
+ <div className="mx-auto max-w-7xl space-y-4">
+ {/* Line boxes the size of PageHeader's title and description. */}
+ <div className="space-y-1">
+ <div className="flex h-8 items-center">
+ <Skeleton className="h-6 w-48" />
+ </div>
+ <div className="flex h-5 items-center">
+ <Skeleton className="h-3.5 w-72 max-w-full" />
+ </div>
+ </div>
+ <SkeletonCard />
+ </div>
+ </div>
+ );
+}
diff --git a/src/client/components/Spinner.tsx b/src/client/components/Spinner.tsx
index b796cd2f..184b26bf 100644
--- a/src/client/components/Spinner.tsx
+++ b/src/client/components/Spinner.tsx
@@ -28,17 +28,13 @@ export function Spinner({
);
}
-/** The centered spinner for a page or section whose data has not arrived. */
-export function PageLoading({
- fullScreen = false,
-}: {
- /** Fill the viewport, for layouts that render before any app chrome. */
- fullScreen?: boolean;
-}) {
+/**
+ * A full-screen spinner for the sign-in and account layouts, which have no app
+ * chrome to show while the session loads. In the app, pages show skeletons.
+ */
+export function PageLoading() {
return (
- <div
- className={`flex items-center justify-center ${fullScreen ? "min-h-dvh" : "py-10"}`}
- >
+ <div className="flex min-h-dvh items-center justify-center">
<Spinner />
</div>
);
diff --git a/src/client/features/ai-search/ResearchPageShell.tsx b/src/client/features/ai-search/ResearchPageShell.tsx
index 9f3f4a1a..6b5d04a6 100644
--- a/src/client/features/ai-search/ResearchPageShell.tsx
+++ b/src/client/features/ai-search/ResearchPageShell.tsx
@@ -8,10 +8,10 @@ import { GateCard } from "@/client/components/GateCard";
import { PageHeader } from "@/client/components/PageHeader";
import { QueryError } from "@/client/components/QueryState";
import {
+ SkeletonCard,
SkeletonStatGrid,
SkeletonTableRows,
} from "@/client/components/SkeletonPresets";
-import { PageLoading } from "@/client/components/Spinner";
import { Badge } from "@/client/components/ui/badge";
import { Button } from "@/client/components/ui/button";
import { Card, CardContent } from "@/client/components/ui/card";
@@ -97,7 +97,7 @@ export function ResearchPageShell<TData>({
/>
{planStatus === "loading" ? (
- <PageLoading />
+ <SkeletonCard />
) : planStatus === "free" ? (
<GateCard
className="mx-auto max-w-3xl"
diff --git a/src/client/features/audit/AuditDetail.tsx b/src/client/features/audit/AuditDetail.tsx
index 510b3650..3c3db80d 100644
--- a/src/client/features/audit/AuditDetail.tsx
+++ b/src/client/features/audit/AuditDetail.tsx
@@ -2,7 +2,7 @@ import { AlertCircle } from "lucide-react";
import { BackButton } from "@/client/components/PageHeader";
import { useQuery } from "@tanstack/react-query";
import { QueryError, QueryState } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import {
Alert,
AlertDescription,
@@ -77,7 +77,7 @@ export function AuditDetail({
// isPending (not isLoading) also covers a fetch paused while offline, so
// past these two returns the status is always loaded.
if (statusQuery.isPending) {
- return <PageLoading />;
+ return <SkeletonPage />;
}
if (statusQuery.isError) {
diff --git a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
index 297443ff..ddb9ba3f 100644
--- a/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
+++ b/src/client/features/lighthouse/issues/LighthouseIssuesParts.tsx
@@ -1,6 +1,6 @@
import { BackButton } from "@/client/components/PageHeader";
import { ExportMenu } from "@/client/components/ExportMenu";
-import { Spinner } from "@/client/components/Spinner";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
import { Card, CardContent } from "@/client/components/ui/card";
import {
Table,
@@ -213,7 +213,7 @@ export function LighthouseIssueList({
emptyMessage?: string;
}) {
if (isLoading) {
- return <Spinner label="Loading issues..." className="p-4" />;
+ return <SkeletonTableRows className="p-4" rows={5} columns={3} />;
}
if (!issues.length) {
return (
diff --git a/src/client/features/projects/ProjectSwitcher.tsx b/src/client/features/projects/ProjectSwitcher.tsx
index 8e1a86a1..ee9d340c 100644
--- a/src/client/features/projects/ProjectSwitcher.tsx
+++ b/src/client/features/projects/ProjectSwitcher.tsx
@@ -17,6 +17,7 @@ import {
} from "@/client/components/ui/combobox";
import { Button } from "@/client/components/ui/button";
import { Separator } from "@/client/components/ui/separator";
+import { Skeleton } from "@/client/components/ui/skeleton";
import type { ProjectSummary } from "./types";
const SEARCH_THRESHOLD = 8;
@@ -31,19 +32,43 @@ function matchesProject(project: ProjectSummary, query: string) {
export function ProjectSwitcher({
activeProjectId,
+ ready,
onCloseDrawer,
}: {
activeProjectId: string | null;
+ /** The session is confirmed, so the projects list can load. */
+ ready: boolean;
onCloseDrawer?: () => void;
}) {
const router = useRouter();
const [creating, setCreating] = React.useState(false);
const [open, setOpen] = React.useState(false);
- const projectsQuery = useQuery(projectsQueryOptions());
+ const projectsQuery = useQuery({ ...projectsQueryOptions(), enabled: ready });
const projects = projectsQuery.data ?? [];
const activeProject =
projects.find((project) => project.id === activeProjectId) ?? null;
+ if (projectsQuery.isPending) {
+ // The loaded switcher's box: a name line, a domain line and the settings
+ // button's slot, so nothing moves when the projects arrive.
+ return (
+ <div
+ className="flex items-stretch rounded-lg border border-sidebar-border bg-card"
+ aria-busy
+ >
+ <div className="flex min-w-0 flex-1 flex-col px-3 py-1.5">
+ <span className="flex h-5 items-center">
+ <Skeleton className="h-3.5 w-28" />
+ </span>
+ <span className="flex h-4 items-center">
+ <Skeleton className="h-3 w-20" />
+ </span>
+ </div>
+ <div className="w-12 border-l border-sidebar-border" />
+ </div>
+ );
+ }
+
const handleSelect = (project: ProjectSummary) => {
setOpen(false);
onCloseDrawer?.();
diff --git a/src/client/features/rank-tracking/KeywordTrendModal.tsx b/src/client/features/rank-tracking/KeywordTrendModal.tsx
index 029f4865..7bbb59e4 100644
--- a/src/client/features/rank-tracking/KeywordTrendModal.tsx
+++ b/src/client/features/rank-tracking/KeywordTrendModal.tsx
@@ -4,7 +4,7 @@ import { reverse, sortBy } from "remeda";
import { toast } from "sonner";
import { useQuery } from "@tanstack/react-query";
import { QueryState } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { Skeleton } from "@/client/components/ui/skeleton";
import { Button } from "@/client/components/ui/button";
import {
Dialog,
@@ -178,7 +178,7 @@ export function KeywordTrendModal({
<QueryState
query={historyQuery}
errorFallback="Failed to load keyword history"
- loading={<PageLoading />}
+ loading={<Skeleton className="h-56 w-full" />}
>
{() =>
maxPerDevice <= 1 ? (
diff --git a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
index 916409c3..416b3516 100644
--- a/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
+++ b/src/client/features/rank-tracking/RankTrackingDomainDetail.tsx
@@ -12,7 +12,7 @@ import {
} from "@/serverFunctions/rank-tracking";
import { AlertTriangle } from "lucide-react";
import { QueryState } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonCard } from "@/client/components/SkeletonPresets";
import { Alert, AlertDescription } from "@/client/components/ui/alert";
import { useHostedPlanGate } from "@/client/features/billing/HostedPlanGate";
import { captureClientEvent } from "@/client/lib/posthog";
@@ -362,7 +362,7 @@ export function RankTrackingDomainDetail({
<QueryState
query={resultsQuery}
errorFallback="Failed to load rank data"
- loading={<PageLoading />}
+ loading={<SkeletonCard />}
>
{(results) => (
<RankTrackingTable
diff --git a/src/client/features/rank-tracking/RankTrackingOverview.tsx b/src/client/features/rank-tracking/RankTrackingOverview.tsx
index cb49bc5d..c7d097dc 100644
--- a/src/client/features/rank-tracking/RankTrackingOverview.tsx
+++ b/src/client/features/rank-tracking/RankTrackingOverview.tsx
@@ -3,7 +3,7 @@ import { useQuery } from "@tanstack/react-query";
import { Area, AreaChart } from "recharts";
import { getRankConfigTrend } from "@/serverFunctions/rank-tracking";
import { QueryState } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { Skeleton } from "@/client/components/ui/skeleton";
import {
ChartGrid,
ChartXAxis,
@@ -91,7 +91,7 @@ export function RankTrackingOverview({
<QueryState
query={trendQuery}
errorFallback="Failed to load position history"
- loading={<PageLoading />}
+ loading={<Skeleton className="h-[220px] w-full" />}
>
{() =>
chartData.length <= 1 ? (
diff --git a/src/client/features/reports/ReportViewer.tsx b/src/client/features/reports/ReportViewer.tsx
index 7861951f..d3f9e7ab 100644
--- a/src/client/features/reports/ReportViewer.tsx
+++ b/src/client/features/reports/ReportViewer.tsx
@@ -1,5 +1,6 @@
import { useState } from "react";
-import { Spinner } from "@/client/components/Spinner";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
+import { Skeleton } from "@/client/components/ui/skeleton";
import { REPORT_IFRAME_SANDBOX } from "@/shared/report-sandbox";
/**
@@ -40,8 +41,14 @@ export function ReportViewer({
}
/>
{loadedSrc !== src ? (
- <div className="absolute inset-0 flex items-center justify-center">
- <Spinner />
+ // A document-shaped placeholder over the frame until the report loads.
+ <div
+ className="absolute inset-0 space-y-3 overflow-hidden p-6"
+ aria-busy
+ >
+ <Skeleton className="h-7 w-2/5" />
+ <Skeleton className="h-4 w-3/5" />
+ <SkeletonTableRows rows={8} columns={4} className="pt-4" />
</div>
) : null}
</div>
diff --git a/src/client/features/sam/SamSidebarPanel.tsx b/src/client/features/sam/SamSidebarPanel.tsx
index a9ef9a47..b1a60d4e 100644
--- a/src/client/features/sam/SamSidebarPanel.tsx
+++ b/src/client/features/sam/SamSidebarPanel.tsx
@@ -10,7 +10,10 @@ import {
import { QueryState } from "@/client/components/QueryState";
import { Badge } from "@/client/components/ui/badge";
import { Button } from "@/client/components/ui/button";
-import { Spinner } from "@/client/components/ui/spinner";
+import {
+ SidebarMenu,
+ SidebarMenuSkeleton,
+} from "@/client/components/ui/sidebar";
import { useSamBetaOptIn } from "./samBetaOptIn";
import { useSamSessions } from "./useSamSessions";
@@ -72,6 +75,17 @@ function ageLabel(timestamp: string): string {
return `${Math.floor(hours / 24)}d`;
}
+/** The chat list's rows while the chats load. */
+export function SamChatListSkeleton() {
+ return (
+ <SidebarMenu aria-busy>
+ {Array.from({ length: 4 }, (_, index) => (
+ <SidebarMenuSkeleton key={index} />
+ ))}
+ </SidebarMenu>
+ );
+}
+
/**
* The sidebar's Chat tab: the active project's chat history plus a new-chat
* button. Selecting (or creating) a session navigates to the SAM route; the
@@ -139,11 +153,7 @@ export function SamSidebarPanel({
<QueryState
query={sessionsQuery}
errorFallback="Failed to load chats."
- loading={
- <div className="flex justify-center py-6 text-muted-foreground">
- <Spinner />
- </div>
- }
+ loading={<SamChatListSkeleton />}
>
{(loadedSessions) =>
loadedSessions.length === 0 ? (
diff --git a/src/client/features/search-performance/SearchPerformanceDimensionSection.tsx b/src/client/features/search-performance/SearchPerformanceDimensionSection.tsx
index ab434a9b..aa27c717 100644
--- a/src/client/features/search-performance/SearchPerformanceDimensionSection.tsx
+++ b/src/client/features/search-performance/SearchPerformanceDimensionSection.tsx
@@ -1,7 +1,7 @@
import type { UseQueryResult } from "@tanstack/react-query";
import { QueryError } from "@/client/components/QueryState";
import { TablePagination } from "@/client/components/table/TablePagination";
-import { Spinner } from "@/client/components/ui/spinner";
+import { SkeletonTableRows } from "@/client/components/SkeletonPresets";
import { GoogleConnectionCard } from "@/client/features/integrations/GoogleConnectionCard";
import { DimensionTable } from "@/client/features/search-performance/SearchPerformanceParts";
import type { getSearchPerformanceTable } from "@/serverFunctions/searchPerformance";
@@ -32,11 +32,7 @@ export function DimensionSection({
onClearFilters: () => void;
}) {
if (tableQuery.isPending) {
- return (
- <div className="flex items-center gap-2 p-8 text-sm text-muted-foreground">
- <Spinner /> Loading…
- </div>
- );
+ return <SkeletonTableRows className="p-4" />;
}
const error = tableQuery.isError ? (
diff --git a/src/client/features/team/TeamSettings.tsx b/src/client/features/team/TeamSettings.tsx
index 3a88ae55..3e0a00f2 100644
--- a/src/client/features/team/TeamSettings.tsx
+++ b/src/client/features/team/TeamSettings.tsx
@@ -9,7 +9,7 @@ import { toast } from "sonner";
import { SectionHeader } from "@/client/components/PageHeader";
import { PermissionHint } from "@/client/components/PermissionHint";
import { QueryError } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonCard } from "@/client/components/SkeletonPresets";
import { Button } from "@/client/components/ui/button";
import {
Table,
@@ -170,7 +170,7 @@ export function TeamSettings() {
{loadError}
{teamQuery.isPending ? (
- <PageLoading />
+ <SkeletonCard />
) : (
<TableCard>
<Table>
diff --git a/src/client/layout/AppShell.tsx b/src/client/layout/AppShell.tsx
index 580470da..6d616dbe 100644
--- a/src/client/layout/AppShell.tsx
+++ b/src/client/layout/AppShell.tsx
@@ -21,10 +21,13 @@ import {
export function AuthenticatedAppLayout({
children,
projectId,
+ ready,
banner,
}: {
children: React.ReactNode;
projectId?: string;
+ /** The session is confirmed. Until then the shell renders but loads nothing. */
+ ready: boolean;
banner?: React.ReactNode;
}) {
const location = useLocation();
@@ -40,7 +43,7 @@ export function AuthenticatedAppLayout({
// pages, which update the remembered project as the user moves between them.
const projectsQuery = useQuery({
...projectsQueryOptions(),
- enabled: !projectId,
+ enabled: ready && !projectId,
});
const rememberedProjectId = getLastProjectId();
const fallbackProjects = projectsQuery.data ?? [];
@@ -55,6 +58,10 @@ export function AuthenticatedAppLayout({
// builds links that self-correct via the route guard once data arrives.
const sidebarProjectId =
projectId ?? fallbackProjectId ?? rememberedProjectId;
+ // No project to show yet, but the list that may name one is still loading
+ // (a first visit to a page without a project in the URL).
+ const sidebarProjectPending =
+ sidebarProjectId === null && projectsQuery.isPending;
// The setup guide is where the modal and banners send the user, so it shows
// neither: a banner there would link to the page the user is already on.
const shouldCheckSeoApiKeyStatus =
@@ -63,7 +70,7 @@ export function AuthenticatedAppLayout({
const seoApiKeyStatusQuery = useQuery({
queryKey: ["seoApiKeyStatus"],
queryFn: () => getSeoApiKeyStatus(),
- enabled: shouldCheckSeoApiKeyStatus,
+ enabled: ready && shouldCheckSeoApiKeyStatus,
});
const isSeoApiKeyConfigured = shouldCheckSeoApiKeyStatus
? (seoApiKeyStatusQuery.data?.configured ?? null)
@@ -99,7 +106,11 @@ export function AuthenticatedAppLayout({
return (
<SidebarProvider className="h-[100dvh] min-h-0 overflow-hidden">
- <Sidebar projectId={sidebarProjectId} />
+ <Sidebar
+ projectId={sidebarProjectId}
+ projectPending={sidebarProjectPending}
+ ready={ready}
+ />
<SidebarInset className="min-h-0 overflow-hidden md:!m-0 md:!mt-2 md:!rounded-none md:!rounded-tl-lg md:border-l md:border-t md:border-sidebar-border md:!shadow-none">
<MobileTopBar />
<SeoApiStatusBanners
@@ -116,10 +127,12 @@ export function AuthenticatedAppLayout({
/>
) : null}
- <GscReEngagementModal
- projectId={sidebarProjectId}
- suppressed={showMissingSeoApiKeyModal}
- />
+ {ready ? (
+ <GscReEngagementModal
+ projectId={sidebarProjectId}
+ suppressed={showMissingSeoApiKeyModal}
+ />
+ ) : null}
</SidebarProvider>
);
}
diff --git a/src/routes/_app/billing.tsx b/src/routes/_app/billing.tsx
index d0edb9d0..3d33ea52 100644
--- a/src/routes/_app/billing.tsx
+++ b/src/routes/_app/billing.tsx
@@ -3,7 +3,7 @@ import { useState } from "react";
import { ErrorState } from "@/client/components/ErrorState";
import { PageHeader } from "@/client/components/PageHeader";
import { QueryError } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import { Button } from "@/client/components/ui/button";
import {
Card,
@@ -92,7 +92,7 @@ function BillingPage() {
const showTopUpError = topUpAmount.trim() !== "" && !isValidTopUp;
if (billingRouteState === "loading") {
- return <PageLoading />;
+ return <SkeletonPage />;
}
if (billingRouteState === "error") {
diff --git a/src/routes/_app/index.tsx b/src/routes/_app/index.tsx
index 8a67df94..285fd48a 100644
--- a/src/routes/_app/index.tsx
+++ b/src/routes/_app/index.tsx
@@ -9,6 +9,7 @@ import {
import { getErrorCode } from "@/client/lib/error-messages";
import { AuthErrorCard } from "@/client/components/AuthErrorCard";
import { QueryError } from "@/client/components/QueryState";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import { StatusScreen } from "@/client/components/StatusScreen";
import { SUBSCRIBE_ROUTE } from "@/shared/billing";
@@ -81,5 +82,6 @@ function IndexRedirect() {
);
}
- return <StatusScreen pending />;
+ // Shaped like the page it is about to open.
+ return <SkeletonPage />;
}
diff --git a/src/routes/_app/p/$projectId/rank-tracking/$configId.tsx b/src/routes/_app/p/$projectId/rank-tracking/$configId.tsx
index 427f1e66..052987e8 100644
--- a/src/routes/_app/p/$projectId/rank-tracking/$configId.tsx
+++ b/src/routes/_app/p/$projectId/rank-tracking/$configId.tsx
@@ -3,7 +3,7 @@ import { createFileRoute, useNavigate } from "@tanstack/react-router";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { getRankTrackingConfigs } from "@/serverFunctions/rank-tracking";
import { RankTrackingDomainDetail } from "@/client/features/rank-tracking/RankTrackingDomainDetail";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import { QueryError } from "@/client/components/QueryState";
import { EmptyState } from "@/client/components/EmptyState";
import { Button } from "@/client/components/ui/button";
@@ -48,7 +48,7 @@ function RankTrackingConfigRoute() {
};
if (configsQuery.isPending) {
- return <PageLoading />;
+ return <SkeletonPage />;
}
if (!configsQuery.data) {
diff --git a/src/routes/_app/p/$projectId/reports/$reportId.tsx b/src/routes/_app/p/$projectId/reports/$reportId.tsx
index a39f5064..6910ca0f 100644
--- a/src/routes/_app/p/$projectId/reports/$reportId.tsx
+++ b/src/routes/_app/p/$projectId/reports/$reportId.tsx
@@ -14,7 +14,7 @@ import {
import { z } from "zod";
import { BackLink, PageHeader } from "@/client/components/PageHeader";
import { QueryError } from "@/client/components/QueryState";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import { Button } from "@/client/components/ui/button";
import {
DropdownMenu,
@@ -93,7 +93,7 @@ function ReportDetailPage() {
}, [projectId, loadedReport]);
if (reportQuery.isPending) {
- return <PageLoading />;
+ return <SkeletonPage />;
}
const loadError = {
diff --git a/src/routes/_app/route.tsx b/src/routes/_app/route.tsx
index 1e5a40e1..893a04f7 100644
--- a/src/routes/_app/route.tsx
+++ b/src/routes/_app/route.tsx
@@ -1,7 +1,7 @@
import { Outlet, createFileRoute, useParams } from "@tanstack/react-router";
import { useHostedAuthRouteGuard } from "@/client/features/auth/useHostedAuthRouteGuard";
import { FreePlanBanner } from "@/client/features/billing/FreePlanBanner";
-import { PageLoading } from "@/client/components/Spinner";
+import { SkeletonPage } from "@/client/components/SkeletonPresets";
import { AuthenticatedAppLayout } from "@/client/layout/AppShell";
import { useOnboardingRedirect } from "@/client/features/onboarding/useOnboardingRedirect";
@@ -16,19 +16,21 @@ function AppRouteLayout() {
const authGate = useHostedAuthRouteGuard();
useOnboardingRedirect();
const { projectId } = useParams({ strict: false });
-
- if (!authGate.canRenderAuthenticatedContent) {
- return <PageLoading fullScreen />;
- }
+ // The shell paints at once, and only the page waits for the session check,
+ // so a full load shows the sidebar and a page skeleton instead of a spinner.
+ const ready = authGate.canRenderAuthenticatedContent;
return (
<AuthenticatedAppLayout
projectId={projectId}
+ ready={ready}
banner={
- projectId && authGate.isHostedMode ? <FreePlanBanner /> : undefined
+ ready && projectId && authGate.isHostedMode ? (
+ <FreePlanBanner />
+ ) : undefined
}
>
- <Outlet />
+ {ready ? <Outlet /> : <SkeletonPage />}
</AuthenticatedAppLayout>
);
}
diff --git a/src/routes/_auth.tsx b/src/routes/_auth.tsx
index f9551f1f..d5fb0674 100644
--- a/src/routes/_auth.tsx
+++ b/src/routes/_auth.tsx
@@ -49,7 +49,7 @@ function AuthPageLayout() {
isHostedMode &&
((isPending && !hasResolvedSession) || session?.user?.id)
) {
- return <PageLoading fullScreen />;
+ return <PageLoading />;
}
return (
diff --git a/src/routes/_authenticated.tsx b/src/routes/_authenticated.tsx
index 319993c6..d60460d5 100644
--- a/src/routes/_authenticated.tsx
+++ b/src/routes/_authenticated.tsx
@@ -33,7 +33,7 @@ function AuthenticatedShellLayout() {
}
if (!authGate.canRenderAuthenticatedContent) {
- return <PageLoading fullScreen />;
+ return <PageLoading />;
}
return (