Files
supabase/apps/www/lib/dashboard-links.ts
anthony lio d885fc7458 feat(www): shared account menu (#53666)
## Problem

- www keeps its own copy of the account menu items separate from the
shared top nav menu in kb and docs
- www header buttons stay hidden until auth loads and the mobile menu
shows no account links during that time
- on app router page such as the home page sign out does not reload the
page

## Solution

- moves the www desktop account menu onto the shared top nav menu so www
docs and kb show the same account items
- fixes "Command Menu" shortcut label to follow the platform, so windows
and linux readers see "Ctrl K"
- changes the header and the mobile menu to read the signed-in mark
while auth loads
- moves the mobile menu account links onto the shared mobile actions, so
www, docs and kb use one component
- changes the desktop "Sign in" links to open the sign-in page, so
desktop and mobile open the same page
- fixes sign out on app router pages so the page reloads after sign out
on every page

<!--
## Preview links

If relevant, include links to changed pages for easy review access.

Copy the preview base URL from the Vercel bot comment on this PR. Use
the following table as an example template.

| Site | Live | Preview | Search for |
| -------------- |
-------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------------------------
| ----------------------------- |
| WWW | [/blog/your-post](https://supabase.com/blog/your-post) |
[/blog/your-post](https://zone-www-dot-com-git-branch-name-supabase.vercel.app/blog/your-post)
| unique phrase from the change |
| Docs |
[/docs/guides/your-page](https://supabase.com/docs/guides/your-page) |
[/docs/guides/your-page](https://docs-git-branch-name-supabase.vercel.app/docs/guides/your-page)
| unique phrase from the change |
| Studio | [/dashboard](https://supabase.com/dashboard) |
[/dashboard](https://studio-git-branch-name-supabase.vercel.app/dashboard)
| unique phrase from the change |
| Design system | [/design-system](https://supabase.com/design-system) |
[/design-system](https://design-system-git-branch-name-supabase.vercel.app/design-system)
| unique phrase from the change |
| UI library | [/library](https://supabase.com/library) |
[/library](https://ui-library-git-branch-name-supabase.vercel.app/library)
| unique phrase from the change |
| Knowledge base |
[/kb/guides/your-page](https://supabase.com/kb/guides/your-page) |
[/kb/guides/your-page](https://kb-git-branch-name-supabase.vercel.app/kb/guides/your-page)
| unique phrase from the change |
-->

<!-- ## Additional context

Optionally add any other context or screenshots.

-->

## Review instructions


1. visit
[homepage](https://zone-www-dot-com-git-antlio-fix-www-shared-account-menu-supabase.vercel.app/)
2. open the browser console, and run this snippet, which stores a fake
dashboard session with no real token:
   ```js
const user = { id: 'test', aud: 'authenticated', email:
'you@example.com', user_metadata: { avatar_url:
'https://github.com/supabase.png' } }
   const key = 'supabase.dashboard.auth.token'
localStorage.setItem(key, JSON.stringify({ access_token: 'a.b.c',
refresh_token: 'r', token_type: 'bearer', expires_in: 3600, expires_at:
Math.floor(Date.now() / 1000) + 3600, user }))
   localStorage.setItem(`${key}-user`, JSON.stringify({ user }))```
3. reload the page

## Checklist

Check all before review:

- [x] I have read
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
- [ ] If I wrote a new docs topic or edited an existing topic, I used
the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs
[style
guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide)
2026-11-24 16:08:54 +02:00

18 lines
806 B
TypeScript

import { DASHBOARD_SIGN_UP_URL } from 'common/constants/dashboard-urls'
export { DASHBOARD_SIGN_IN_URL, DASHBOARD_SIGN_UP_URL } from 'common/constants/dashboard-urls'
export const DASHBOARD_URL = 'https://supabase.com/dashboard'
/** Homepage/product "Start your project" CTA: sign-up for guests, dashboard for signed-in users. */
export function getDashboardCtaHref(isLoggedIn: boolean): string {
return isLoggedIn ? DASHBOARD_URL : DASHBOARD_SIGN_UP_URL
}
const DASHBOARD_CTA_HREFS = new Set([DASHBOARD_URL, DASHBOARD_SIGN_UP_URL])
/** Rewrite static dashboard/sign-up CTA hrefs when the visitor is already signed in. */
export function resolveDashboardCtaHref(href: string, isLoggedIn: boolean): string {
if (!DASHBOARD_CTA_HREFS.has(href)) return href
return getDashboardCtaHref(isLoggedIn)
}