Cloudrive

Routing

File-based TanStack Router routes, grouped by audience, with guards in layout routes.

Routes live in src/routes. Folders in parentheses are pathless groups: they add a layout without adding a URL segment.

URLFileNotes
/index.tsxRedirects to /dashboard (public marketing lives in apps/main-web)
/sign-insign-in/index.tsxRedirects to /dashboard with a session
/auth/callbackauth/callback.tsxMagic-link and Google sign-in landing
/onboardingonboarding/index.tsxFirst-run wizard
/dashboard(dashboard)/dashboard/index.tsxWorkspace overview
/drive, /shared, /recent, /starred(dashboard)/*/index.tsxViews over the merged drive
/storage(dashboard)/storage/index.tsxConnected storage accounts
/settings(dashboard)/settings/index.tsxTabs via ?tab=: storage, s3, account, organizations, workspaces
/organizations/$orgId(dashboard)/organizations/$orgId.tsxOrganization detail
/workspaces/$wsId(dashboard)/workspaces/$wsId.tsxWorkspace detail
/organizations, /workspaces, /providers, /s3(dashboard)/*/index.tsxRedirects into the matching settings tab
/previewpreview/index.tsxDev-only mock dashboard (404 in production)

Layout routes

  • (marketing)/route.tsx wraps the public pages in <div className="marketing">, which switches to the marketing palette and font (see Styling).
  • (dashboard)/route.tsx renders DashboardGate (components/block/auth/dashboard-gate.tsx):
    • no session → /sign-in;
    • a session but no organization → /onboarding;
    • otherwise the sidebar shell with the page inside.
  • __root.tsx mounts the providers (theme, nuqs, tooltips), the toaster, <HeadContent /> for per-route titles, and the 404/error pages. Devtools load only in development.

Titles and meta

Static defaults (title, description, Open Graph, Twitter cards) are in index.html, because crawlers do not run the SPA. A route sets its own title through head:

export const Route = createFileRoute('/(dashboard)/storage/')({
  head: () => ({ meta: [{ title: 'Storage Accounts | Cloudrive' }] }),
  component: StorageContent,
})

Most dashboard links keep the active organization and workspace in ?org= and ?ws=. TanStack Router matches to as a path only, so never put a query string in to:

// static: pass search explicitly
<Link to="/settings" search={{ tab: 'workspaces' }}>Workspaces</Link>

// built URLs (scoped hrefs): split them with hrefToLocation
<Link {...hrefToLocation(scopedHref('/storage'))}>Storage</Link>
void navigate(hrefToLocation('/storage?org=…&ws=…'))

hrefToLocation lives in lib/utils.ts. The settings route declares validateSearch for tab and view so typed navigate({ to: '/settings', search: { tab } }) compiles.

On this page