Skip to content
Back to skills

Admin Shell

ASecurity

Core owns the admin shell: the `/admin` parent route, the login page, the route guard, the admin banners, and the top navbar with the user menu. A backend layer does not write these. It registers an auth driver, and core renders the shell from it. This file covers steps P1 (the contract), P2 (the core navbar), P3 (the routes and the guard) and P4 (the standalone CMS as the reference driver) of the "core-owned admin shell" refactor. The supabase layer migrates later. See "Migrating a backend t...

  • 4 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 7, 2026
developmentgoshellsqlreactvueawsgitdatabasebackend

Works with

  • cli

Security analysis

A100/100

Scanned November 24, 2026

npx -y skills add plutocms/pluto --skill admin-shell --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Admin Shell?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Admin Shell
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/plutocms-admin-shell/badge)](https://www.skillsdirectory.com/skills/plutocms-admin-shell)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Admin shell

Core owns the admin shell: the `/admin` parent route, the login page, the route guard, the admin
banners, and the top navbar with the user menu. A backend layer does not write these. It registers
an auth driver, and core renders the shell from it.

This file covers steps P1 (the contract), P2 (the core navbar), P3 (the routes and the guard) and
P4 (the standalone CMS as the reference driver) of the "core-owned admin shell" refactor. The
supabase layer migrates later. See "Migrating a backend to the auth driver".

It extends the [extension registry](../extension-registry/SKILL.md).

## The auth driver

A layer sets `authDriver` in `definePlutoExtension`. The last registered driver wins, like the
other drivers. `PlutoAuthDriver` (in `shared/types/registry.ts`) has:

| Field                              | Purpose                                                                                                             |
| ---------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
| `user()`                           | The signed-in `PlutoAuthUser` (`id`, `name`, `username`, `email`, `avatarUrl`), or `null`.                          |
| `loggedIn()`                       | Optional. Default is `user() !== null`.                                                                             |
| `ready()`                          | A promise. It resolves after the first session check. It never rejects.                                             |
| `refresh()`                        | Optional. Reads the session again.                                                                                  |
| `signOut()`                        | Ends the session. Core then shows a toast and goes to `/admin/login`.                                               |
| `signIn`                           | The sign-in form component. Core passes `PlutoAuthSignInProps` (`redirect`).                                        |
| `signInTitle`, `signInDescription` | Key-or-literal text for the login frame.                                                                            |
| `links`                            | `signUp` and `forgotPassword` URLs.                                                                                 |
| `publicPaths`                      | Paths that need no sign-in. A string, or `{ path, signedIn: 'redirect' \| 'allow' }`. `/admin/login` is always one. |

`user` and `loggedIn` are getters, not refs. They read reactive state of the backend.

### The hydration rule

`loggedIn()` must give the same answer on the server and in the first client render.

- A backend with a cookie session that the server can read (supabase) can answer on the server.
  The navbar then renders in the server HTML.
- A backend that learns the session in the browser (the standalone CMS) answers `false` on the
  server. The navbar then appears after hydration.

Core adds no `ClientOnly` around the whole bar and uses no top-level await in it.

## Other buckets

| Field          | Type                     | Purpose                                                                                 |
| -------------- | ------------------------ | --------------------------------------------------------------------------------------- |
| `accountMenu`  | `PlutoAccountMenuItem[]` | Items in the user menu. `label` is key-or-literal. Sorted by `order`.                   |
| `adminBanners` | `PlutoAdminBanner[]`     | Banner components for the admin. The admin layout renders them. See "Admin banners".    |
| `site`         | `PlutoSiteInfo`          | `name()` and `url()` of the public site. For each field, the last value wins.           |
| `backend`      | `PlutoBackendInfo`       | The backend badge of the navbar. The last registered one wins. See "The backend badge". |

## Routes

| File                                 | Route                   | Purpose                                                                                                     |
| ------------------------------------ | ----------------------- | ----------------------------------------------------------------------------------------------------------- |
| `app/pages/admin.vue`                | `/admin` (parent)       | `definePageMeta({ layout: 'admin' })` and `<NuxtPage />`. Every `/admin/**` page is a child.                |
| `app/pages/admin/(auth)/login.vue`   | `/admin/login`          | The login page. It sets the `auth` layout and renders `PlutoAdminAuthCard`.                                 |
| `app/pages/admin/no-access.vue`      | `/admin/no-access`      | The page for a signed-in user with no capability. It uses the `auth` layout. See "The staff step".          |
| `app/pages/admin/not-configured.vue` | `/admin/not-configured` | The page for an admin with no auth driver, in production. It uses the `auth` layout. See "The route guard". |

A child that must not use the admin layout (the auth pages) sets its own layout in
`definePageMeta`. The `(auth)` folder is a route group: it adds no path segment.

The file paths are the contract. The supabase layer 0.10 ships the same paths, so in a supabase app
its files override core's files. This is intended until supabase migrates. A different path for
the login page would give two `/admin/login` routes in a supabase app.

`/admin` redirects to `/admin/home` with the core `routeRules` entry in `nuxt.config.ts`, and
`/admin/**` has `ssr: false`. The admin is client-only, so the guard below runs in the browser for
these paths.

## The route guard

`app/middleware/pluto-admin-auth.global.ts` is a global route middleware.

1. It never touches a path outside `/admin`.
2. With no auth driver, `driverDecision` decides. In production, every admin path goes to
   `/admin/not-configured`: both backends register a driver, so no driver means the backend is
   missing or did not load (the Git CMS turns off with no repo), and the admin pages must not show
   to everyone. In dev, the admin opens, so admin pages can be built with no backend. With a
   driver, `/admin/not-configured` goes to the admin home. The server routes refuse every call
   with no driver in both cases; this step only decides what the browser shows.
3. It awaits `driver.ready()`. A rejection counts as signed out.
4. It calls `driver.guard(to)` when the driver has one. A returned local path that is not the
   current path is a redirect. Nothing returned, or a rejection, goes on to the next step. Supabase
   uses this hook to send a new install to `/admin/setup` before the sign-in rule.
5. It calls `guardDecision` with `normalizePublicPaths(driver.publicPaths)`. On a redirect, it calls
   `navigateTo(to, { replace: true })`.

6. The staff step (see below). It runs only for a signed-in user on a private admin path.

A signed-out user on a private admin path goes to `/admin/login?redirect=<fullPath>`. A signed-in
user on a public auth path goes to the checked `redirect` target, or to `/admin/home`. The server
still checks every request. The guard only decides what the browser shows.

## The staff step

Only staff can enter the private admin pages. Staff is a user with at least one capability (an
admin holds `*`). With no permissions driver, every signed-in user counts as staff, like `can()`
that fails open. The rule is `isStaff(hasDriver, granted)` in `internal/admin-shell.ts`. The navbar
uses the same function. The server RLS uses the same meaning (`my_capabilities()` is not empty).

After `guardDecision` allows a signed-in user, the middleware awaits
`usePlutoPermissions().ensureLoaded(userId)` and calls the pure `staffDecision`:

- A path outside `/admin`, and a public auth path of the driver: allow. They are never checked.
- Staff on a private path: allow.
- No capability: go to `/admin/no-access?redirect=<fullPath>`.
- The capabilities failed to load: go to `/admin/no-access?reason=error&redirect=<fullPath>`.
- On `/admin/no-access`: staff go to the checked `redirect` target, or to `/admin/home`. A user who
  is not staff stays. This keeps the guard free of a redirect loop.

The auth sync plugin and the middleware both ask for the same list. `ensureLoaded` shares one
request between them, so there is no race. A Git CMS app is not affected: every CMS user has
capabilities.

`navbarVisible` hides the bar on `/admin/**` when the capabilities are known and the user is not
staff. So the no-access page has no admin bar.

### The no-access page

`/admin/no-access` uses the `auth` layout and `PlutoAdminAuthCard`. It shows "Your account has
no access to the admin", or an error text for `reason=error`. It has three actions:

- Try again: clears the capabilities, loads them again, then goes to `redirect` or `/admin/home`
  for staff. A user who is still not staff stays.
- Go to the site: `/`.
- Sign out: `usePlutoAuth().signOut()`.

The texts are in `pluto.noAccess.*`, in English and Brazilian Portuguese. The tab title is the
heading.

## The login frame

`PlutoAdminAuthCard` (`app/components/Pluto/Admin/PlutoAdminAuthCard.vue`) is the frame of the login
page. The name follows the folder rule of Nuxt: a file `PlutoAuthCard.vue` in `Admin/` would be
`PlutoAdminPlutoAuthCard`. The card has:

- The logo and the site name (`site.name()`, else `websiteName`, hidden when `Untitled`).
- The heading: `signInTitle` (key-or-literal), default "Sign in". The description is
  `signInDescription`.
- The `signIn` component of the driver, with the prop `redirect`. The login page gives it
  `safeRedirect(route.query.redirect)`: a local path or an empty string.
- The footer links `links.signUp` and `links.forgotPassword`, when the driver gives them.
- A "Back to the site" link.
- Below the card, `PlutoAdminLanguageSelect`: the admin language (Automatic and each admin locale,
  named in its own language). It switches on this device only (`setLocale(code, { save: false })`),
  and the next sign-in saves it to the user. It hides when the admin has one language. Every page
  that uses the card gets it (login, no access, and the auth pages of a backend).

The card also frames the other auth pages of a backend (sign up, password reset). Give it a
default slot, and the slot replaces the driver's form and links. The props `title` and
`description` (key-or-literal) replace the heading. Example:

```vue
<PlutoAdminAuthCard title="supabase.auth.signup.title">
  <SignUpForm />
</PlutoAdminAuthCard>
```

`wide` makes the card 32rem wide (a longer form). The `partner` slot goes after the logo, for a
page that connects the site to a service (the database setup of the Supabase layer: an arrow and
the Supabase mark). With it, the Pluto logo is the planet only (`PlutoLogo mark`), and the site name is
muted at the end of the row. A white-label logo stays as it is.

With no driver and no slot, the card shows an alert: no sign-in method is set up. The texts are in
`pluto.auth.*`, in English and Brazilian Portuguese.

## Admin banners

The admin layout renders the `adminBanners` bucket, sorted by `order`, at the top of the page
content. They are below the fixed navbar and above the page. A banner is a component with no props.
It decides for itself if it shows.

## The CMS as the reference driver

The standalone CMS (`modules/pluto-github`) is the first backend on the driver. Its client plugin
registers `authDriver` and nothing else for the shell. See the [git-cms](../git-cms/SKILL.md)
skill.

- `user()` maps the session: GitHub login to `username`, plus `name` and `avatarUrl`.
- `loggedIn()` reads the session, which loads in the browser only. It is `false` on the server and
  in the first client render. The hydration is stable, and the bar appears after hydration.
- `ready()` waits for the first session read. `refresh()` reads it again. `signOut()` posts to the
  logout route.
- `signIn` is `PlutoGithubSignIn` (in `app/components/Pluto/Github/`, so Tailwind scans it). It builds the
  login URL from `redirect` and shows the sign-in error alert.
- The module adds no page, no route middleware and no navbar.

Core moves a public page down under the bar (see "The height token and the `<html>` marker"). A
public layout with a sticky or fixed header offsets that header with `usePlutoAdminBar().visible`
or the `data-pluto-admin-bar` marker on `<html>`. Both are in the server HTML when the hint puts
the bar there, so the offset is in the first paint too.

## Who sees the navbar

The rule is `navbarVisible` in `app/composables/internal/admin-shell.ts`. `usePlutoAdminBar()`
returns `{ visible, confirmed }`. `visible` follows the rule; an app that offsets its own header
can use it. `confirmed` is true only for a staff user that the browser checked (never from the
hint alone). Use it for links that must not show before that check.

- On `/admin/**`: any signed-in user, except on the public auth paths of the driver, and except a
  user who is known to be no staff (the no-access page).
- On a public page: staff only. Staff is a user with at least one capability, or `*`. A shop
  customer (signed in, no capability) never sees the bar.
- With no permissions driver, every signed-in user counts as staff. This matches `can()`, which
  fails open.
- A route can hide the bar with the page meta `definePageMeta({ plutoAdminBar: false })`
  (`navbarVisible` input `hiddenByRoute`). The preview path `/_pluto/preview` and its children hide
  it too (`isPlutoPreviewPath(path)`, auto-imported, `shared/utils/preview-path.ts`). The block
  editor shows that path in an iframe, so the iframe must not show the bar. An app can use
  `isPlutoPreviewPath` to skip its own header and footer there.

### How the bar avoids a flash and a hydration mismatch

Capabilities load in the browser. `app/plugins/pluto-auth-sync.client.ts` watches `loggedIn`. On
sign-in it loads the capabilities and syncs the admin language. On sign-out it clears the
capabilities. It also sets `usePlutoCapabilitiesKnown()`, a state that is `true` only after the
capabilities loaded in the browser. The server never sets it.

- On a public page, the real rule needs `capabilitiesKnown` and `usePlutoAppMounted()`. The second
  one becomes `true` at the first `app:suspense:resolve`, when Nuxt ends the hydration. The
  capabilities alone are not enough: with no permissions driver, or a fast session read, they can
  be known before hydration.
- A customer never sees the bar, because the real rule waits for the answer.
- On `/admin/**` the bar does not wait. It renders from `loggedIn()`. The admin is client only.

### The bar in the first paint (the hint cookie)

The server does not know the session of every driver, so it cannot apply the real rule. A hint
lets it render the bar anyway:

- The auth sync plugin writes the cookie `pluto-admin-bar` (`ADMIN_BAR_HINT_COOKIE`, 30 days,
  `SameSite=Lax`, not httpOnly) once the session is settled: `true` for a confirmed staff user,
  removed for anybody else (signed out, or no staff).
- `usePlutoAuthSettled()` is `true` after the driver is `ready()` and, for a signed-in user, the
  capabilities finished loading (or failed). It is `false` on the server.
- `usePlutoAdminBarHint()` reads the cookie on the server into a `useState`, so the payload carries
  it and the first client render matches the server HTML.
- `navbarVisible` input `hint` is `hint && !(mounted && settled)`. On a public page, with the
  capabilities not known, the hint shows the bar. Once the browser knows the session, the real
  rule decides. A wrong hint (the session ended elsewhere) hides the bar and removes the cookie.
- The bar frame is in the server HTML: the menu button, the logo and the site name. The navbar
  actions and the user menu are `ClientOnly` with a placeholder, so they load after the mount.
  The bar holds no user data in the server HTML.
- A response rendered with the hint gets `Cache-Control: private, no-store` (`PlutoRoot`), so a
  shared cache does not keep it. A prerendered page has no cookie, so it has no bar in its HTML;
  the bar appears after the mount there, as before.

The first visit of a staff user (no cookie yet) shows the bar after the capabilities load. Every
later page load has it in the first paint. If the capabilities load fails, the bar hides.

### The height token and the `<html>` marker

- `--pluto-admin-bar-height: 2.5rem` is on `:root` in the plain `<style>` of `PlutoRoot`, so a
  site with no Tailwind has it too. `PlutoNavbarAdmin` (`h-(--pluto-admin-bar-height)`)
  and the admin layout (the dashboard group `top`) read it. A site that offsets its own header
  under the bar reads it too.
- `--ui-header-height: 2.5rem` stays on `:root`, so an existing app does not change. A site with a
  taller header can set its own `--ui-header-height` (for example for the public pages only) and
  the admin bar keeps its height.
- **The root (no `PlutoRoot` to write).** The `pluto-root` module (`modules/pluto-root`, config key
  `plutoRoot`) reads the main component in `app:resolve` (`app.mainComponent`, the `app.vue`; not `app.rootComponent`, the internal `nuxt-root.vue`) (`inspectRootComponent`, a text
  check for `<PlutoRoot` and `<UApp`, test `test/pluto-root.test.ts`). A root with `PlutoRoot`
  stays as it is. Any other root (the `app.vue` of the app, of a theme layer such as Docus, or the
  default one of Nuxt) is replaced by `modules/pluto-root/runtime/PlutoAppRoot.vue`, and the
  template `#build/pluto/site-root.mjs` exports the original root and `siteHasApp`. The admin and
  the preview path get `PlutoRoot` + `NuxtPage`: the site root, its header, layout and top-level
  awaits never run there. A public page gets `<PlutoRoot own-layout :own-app="siteHasApp">` around
  the site root. A dev log line says that the root is wrapped and whether it has its own `UApp`.
  Options: `plutoRoot.wrap: false` (no wrapping), `plutoRoot.siteApp` (`'auto'`, or `true`/`false`
  when the `UApp` of the site is in a layout or a component, which the text check cannot see).
- `PlutoRoot` props: `ownLayout` renders the slot with no `NuxtLayout` (the site root decides its
  layout). `ownApp` (the slot has its own `UApp`): on a public route PlutoRoot renders the slot, then
  the admin bar (`PlutoAdminNavbarProvider`, the admin menu) in reka-ui `ConfigProvider` +
  `TooltipProvider` only: a second `UApp` would show each toast and overlay twice, because their
  state is global. The head, the html attributes and the plain `<style>` are the same. On an admin
  route both change nothing.
- **The header offset** is core's and needs no site CSS. `app/app.config.ts` gives every `UHeader`
  the class `pluto-header-offset`. The plain `<style>` of `PlutoRoot` copies
  the site's `--ui-header-height` to `--pluto-site-header-height` on `<body>` (always, outside the admin: a site uses it, the docs hero for one), and while the bar shows adds the bar to
  `--ui-header-height` on `#__nuxt` (two elements: a property that reads itself on one element is
  a cycle), and gives `.pluto-header-offset` `top: bar` and the site height. The page aside, the
  table of contents and the anchor margin read `--ui-header-height`, so they stick under the bar
  too. Limits: a header that is not a `UHeader` needs the class; a site that sets
  `--ui-header-height` on an inner element (Docus `navigation.sub: 'header'`) keeps its own value
  there, so its sticky parts are the bar height off; overlays teleported to `<body>` read the site
  value.
- `PlutoRoot` sets `data-pluto-admin-bar="true"` on `<html>` while
  `usePlutoAdminBar().visible` is `true`. It follows the bar, so it is in the server HTML when
  the hint puts the bar there. The server uses `useHead` `htmlAttrs`. The browser uses a watch
  that sets or removes the attribute on `document.documentElement` directly. Do not move it back
  to `useHead` in the browser: unhead removes only the attributes that it rendered in the browser.
  With a stale hint (the session ended), the bar hides before the first head render, so the
  attribute of the server HTML stayed, and the page kept the gap of the bar. A site can write
  `:root[data-pluto-admin-bar] .site-header { top: var(--pluto-admin-bar-height) }`.
- The page offset is in core. While the marker is on `<html>` of a public page (not
  `data-pluto-admin`), the plain `<style>` of `PlutoRoot` gives `body` a `padding-top` of the bar
  height, `<html>` a `scroll-padding-top` of the same value, and `#__nuxt` a `min-height` of
  `--pluto-page-height`, so a short page does not scroll. `--pluto-page-height` is `100dvh`, less
  the bar while it shows (both rules in `:where()`). A site layout with a footer at the bottom
  uses it: `min-h-(--pluto-page-height)`, no script. The selectors are in `:where()`, so a
  rule of the site wins. A site adds no offset of its own for the page; a sticky or fixed header
  still needs `top: var(--pluto-admin-bar-height)` (`pluto-site-header` of the site theme does it).

## What the navbar has

`PlutoAdminNavbar` (in `app/components/Pluto/Admin/`) wraps the `PlutoNavbarAdmin` 40px bar. In
order:

1. The menu button, for small screens (`usePlutoAdminMenuOpen`).
2. The logo (a brand logo with `appConfig.pluto.brand`, see the white-label skill) and the site name chip. Below `sm` the logo is the planet only (`PlutoLogo mark`),
   and the chip is hidden. From `sm` the logo has the wordmark, and the site name shows as a
   rounded chip. The name is `site.name()`, else `runtimeConfig.public.websiteName`. The chip is
   hidden when the name is empty or `Untitled`.
3. The navbar actions, inside `ClientOnly` with a spinner fallback. Core adds one: the content
   bar actions (see "Content buttons"), for example "New Post".
4. "View site", on `/admin/**` only. It opens `site.url()`, else `/`. The title is
   "Visit {domain}".

At the right end:

5. The backend badge, on `/admin/**` only, in `ClientOnly`, next to the user. Its popover aligns
   to the end. See "The backend badge".
6. `PlutoAdminUserMenu`, only when a driver is registered. It is `ClientOnly`, with an avatar
   skeleton as the fallback.

The navbar has no border under it, and the sidebar has no border. The dashboard group has the navbar
color, and the dashboard panel has `lg:rounded-ss-xl overflow-hidden`. The bar and the sidebar read as
one shape with a rounded inner corner. The action list has `gap-x-0.5`.

The user menu has the avatar and the short name. An administrator (`usePlutoPermissions().isAdmin`:
the capability `'*'`) gets a warning chip on the avatar, an "Admin" badge (`pluto.navbar.adminBadge`,
title `pluto.navbar.administrator`) at the end of the dropdown header (the `account` item slot,
`#account-trailing`), and "Administrator" in the accessible name of the button. The badge is not in
the bar: it pushed the avatar out on narrow widths. The supabase `admin` role and a GitHub user with
admin or maintain access hold `'*'`. The dropdown has an account header (avatar, name, the email or `@username`, and the Admin badge), a
Theme row (`pluto.navbar.theme`), Settings (`meta+,`), the `accountMenu` items, the brand links ("Help" from `brand.helpUrl`, the agency from `brand.url`), "Pluto on GitHub" (`plutocms/pluto`, hidden with `brand.plutoLinks: false`) and Sign out
(`meta+shift+q`). The Theme row is a Light/Dark/System segmented control
(`pluto.navbar.themeLight`, `themeDark`, `themeSystem`). A click on an icon sets the mode. Enter on the
row cycles the mode. The row is hidden when the color mode is forced. The menu follows the admin color
mode (`usePlutoAdminPortal({ dark: false })`). The default of `usePlutoAdminPortal()` is dark, and the
content bar actions menu uses it. Shortcuts use `defineShortcuts(extractShortcuts(items))`.
`PlutoAdminNavbarProvider` shows the bar when `usePlutoAdminBar().visible` is true.

## The backend badge

The badge tells the editor where the content goes: "Git · Local", "Git · GitHub" or
"Database · Supabase". The backend registers it with the `backend` field of
`definePlutoExtension` (registry bucket `backend`). `usePlutoBackend()` gives the last registered
entry, with `label` and `countLabel` translated, and `count` cleaned to a whole number of 0 or more.
It is `null` with no backend, and then no badge shows.

`PlutoBackendInfo`:

- `kind`: `git` or `database`. It picks the first word ("Git", "Database",
  `pluto.backend.kind.*`) and the fallback icon (`i-lucide-git-branch`, `i-lucide-database`).
- `label`: key-or-literal, the name after the kind.
- `icon`: the icon of the provider, in the badge and in the popover header. The provider sets it.
  The official backends follow one pattern, a Lucide line icon: `i-lucide-github` (GitHub mode),
  `i-lucide-git-branch` (local mode), `i-lucide-database-zap` (the supabase layer). An official
  backend added later (MySQL, Turso, Neon, ...) picks a Lucide line icon too. A community backend
  can use any icon. Default: the icon of the kind.
- `count()` and `countLabel`: a number on the badge as a warning pill, for example the commits that
  are not pushed. `countLabel` is a plural key-or-literal with `{count}`, used as the title of the
  pill and in the accessible name. 0 shows nothing.
- `details`: the popover body. Use an async component (the dev warning checks it).
- `onOpen()`: called when the popover opens, for example to read the state again.

`PlutoAdminBackendBadge` (`app/components/Pluto/Admin/`) is a `PlutoNavbarHit` in a `UPopover`.
Below `md` only the icon and the count show. The popover has the label, one line for the
mode (`pluto.backend.gitMode`, `databaseMode`) and the `details` component. The Git CMS and the
supabase layer register one each. Tests: `test/auth-driver.test.ts` ("backend"),
`test/async-component.test.ts`.

### Full-height click area

Each control in the bar fills the full height of the bar (39px).
`PlutoNavbarHit` does this. It is a link (with `to`) or a button (without) that is `h-full`.
The visible pill is a ghost `UButton` rendered as a `<span>` inside it. The span takes no
pointer events. It gets the hover, active and focus-visible look from the `group` classes of the
link, so the pill looks the same as before. Use `PlutoNavbarHit` for a new control. Do not put a
plain `UButton` in the bar. `PlutoAdminUserMenu` uses the same pattern with its own pill.

A dropdown of the bar renders in a portal target that has `data-pluto-admin-scope`, so the menu has
the admin theme and the admin radius on a public page. `usePlutoAdminPortal()` makes the target at
the end of `<body>>`, not inside the navbar. The navbar is fixed with a z-index, so it makes a stacking
context. A menu inside it cannot show above a site header with the same z-index. Pass
`portalTarget ?? true` to the `portal` prop of `UDropdownMenu`. The user menu and the "New" menu use it.

## Tab title

`PlutoRoot` sets the `titleTemplate` on admin routes only: "Page - Site name". The site name is
`site.name()`, then `runtimeConfig.public.websiteName` (not `Untitled`), then `pluto.app.name`
(`resolveSiteName`). Public routes keep the title template of the app. Every page under
`app/pages/**` sets `useHead({ title: () => t('...') })`. Content pages use the labels of
`usePlutoContentText`.

Texts are in `pluto.navbar.*`, in English and Brazilian Portuguese. The words are "Sign in",
"Sign out" and the default name "Account".

## Link actions

A `navbarActions` entry is a component action (`{ id, component }`) or a link action
(`PlutoNavbarLinkAction`): `{ id, label, icon?, to, target? }`. `to` can be a function. Core
renders a link action with `PlutoNavbarButton`: a ghost, neutral, small `UButton` with the icon.
The label shows from the lg breakpoint. Below it, the label is the aria-label. A component action
renders as before.

## Content buttons

Core registers one navbar action (`id: 'content'`, order 50): `PlutoContentBarActions`. A content
type asks for its buttons with `adminBar` (`true`, or `{ new?, edit? }`; see the content-model
skill). The `write` capability of the type decides; with no `write` capability, the button shows.

- "New <type>" on every page where the bar shows. The link is `contentTypeNewPath(type)`. With one
  type that can show a New button, the bar shows "New <type>". With two or more types, it shows one
  "New" button (`pluto.content.newMenu`, the plus icon) that opens a `UDropdownMenu`
  (`buildNewMenu` in `internal/new-menu.ts`). The types without a `navGroup` are direct items first
  (singular label, type icon, new page). A group with two or more types is a submenu after them (the
  label and icon of the group, one link per type). A group with one type shows that type as a direct
  item. When the only entry is one group (every type is in it), the menu lists its types directly. The groups follow the order of the group. The menu opens aligned to the start of the button,
  has an arrow, and the trigger keeps the pressed background while the menu is open
  (`group-data-[state=open]:bg-elevated` in `PlutoNavbarHit`). The button is an `<li>` with a
  `PlutoNavbarHit` trigger, and the menu uses `usePlutoAdminPortal`. The user menu has an arrow too.
  The New menu also opens on hover: after 120 ms on the button, and it closes 200 ms after the pointer
  leaves the button and the portal target (the menu and its submenus render there, so a move into
  the menu or a submenu keeps it open). It is a controlled `open`. Touch has no hover, so a tap
  opens it. A click on a menu that the hover opened keeps it open (the dropdown would close it, as
  the button counts as outside). Keyboard works as before. The user menu does not open on hover.
- "Edit <type>" on a public page that called `usePlutoEditLink(type, id)`. The link is
  `contentTypeEditPath(type, id)`. It does not show on `/admin/**`: the form has its own View link.

`usePlutoEditLink(type, id)` records the item on screen in `usePlutoCurrentContent()` (browser
only, cleared on unmount, the owner check keeps the next page's value). It returns the edit path
for a confirmed staff user with the capability, else `null`, so a page can show its own link too.

The Git CMS post type sets `adminBar: true`. The core blog template calls
`usePlutoEditLink('post', slug)` on the post page.

`PlutoRoot` shows the public-page admin menu (`PlutoNavbarAdminMenu`) whenever the bar shows on a
public page.

## Migrating a backend to the auth driver

Written for the supabase layer. It also fits any other backend. The supabase layer keeps its own
files until it migrates. After it migrates, core owns the shell.

Register:

1. One `authDriver` in `definePlutoExtension`. Map the supabase user to `PlutoAuthUser`. Make
   `loggedIn()` readable on the server (the cookie session), so the bar renders in the server HTML.
   `ready()` resolves after the first session check and never rejects.
2. `signIn`: the email and password form, as a component. It gets the `redirect` prop. It logs in
   and goes to `redirect`, else `/admin/home`. Keep it in `app/` so Tailwind scans it.
3. `signInTitle`, `signInDescription` and `links` (`signUp: '/admin/signup'`,
   `forgotPassword: '/admin/forgot-password'`).
4. `publicPaths` for the other auth pages: `/admin/signup`, `/admin/forgot-password`,
   `/admin/update-password`, `/admin/confirm`. Use `{ path, signedIn: 'allow' }` for a page that a
   signed-in user must still open (`update-password`, `confirm`).
5. `accountMenu` items for what the layer adds to the user menu, and `site` for the site name and
   URL.
6. A permissions driver and a locale driver, as before. Core syncs both after sign-in.

Delete:

- `pages/admin.vue`. Core's parent route replaces it. Move its extra work to a banner
  (`adminBanners`, for example the migrations banner) or to a plugin.
- The `(auth)/login.vue` frame. Keep the other `(auth)` pages with the `auth` layout. Wrap their body in
  `PlutoAdminAuthCard` (default slot, `title` prop), so every auth page has the same frame. Do not keep a file at the core login path.
- The `auth` route middleware. Core's guard replaces it.
- A named setup middleware that must run before the sign-in rule. Move its check into
  `driver.guard`. Nuxt runs the global middleware of an extended layer (core) before the app's
  own, so a file prefix such as `00.` cannot put a layer's middleware first.
- Any navbar of its own. Core renders the only navbar.
- The permissions and locale sync plugins. `app/plugins/pluto-auth-sync.client.ts` does both.

Rename `setup-check`. It is not an auth concern: it sends a new install to `/admin/setup`. Keep
it as its own setup guard (a route middleware), and add `/admin/setup` to `publicPaths`. Do not run
it inside the auth middleware.

## Tests

- `test/admin-shell.test.ts` — paths, `safeRedirect`, `guardDecision`, `staffDecision`, `isStaff`,
  `navbarVisible`, names.
- `test/permissions.test.ts` — also covers `ensureLoaded` (one request in flight, reload on a new user).
- `test/auth-driver.test.ts` — `validatePlutoAuthDriver`, last driver wins, account menu order,
  site info.
- `test/github-module.test.ts` — the CMS module adds no page and no route middleware.
- The routes, the login page and the guard have no unit test beyond `guardDecision`. Check them in
  a built app: one `/admin/login` route, with the CMS on and with no driver.

## Page height and sticky headers

`PlutoRoot` styles `#__nuxt` with `min-height: 100dvh` and a flex column. It sets no fixed height
on `html`, `body` or `#__nuxt` for public pages. A fixed `height: 100%` would cap each wrapper at
one viewport. A sticky element (for example a Nuxt UI `UHeader`) sticks only inside its parent, so
a capped parent made the header leave after one viewport of scroll.

The admin keeps the fixed height: `:root[data-pluto-admin]` (set by `usePlutoAdminTheme`) gives
`html`, `body` and `#__nuxt` `height: 100%`. The dashboard group is `fixed inset-0`, so it does
not depend on it.

## The Pluto logo

`PlutoLogo` (`app/components/Pluto/PlutoLogo.vue`) is `public/img/pluto.svg` inline. The planet
keeps its colors in both color modes. The wordmark uses `currentColor`, so set a text color class
(`text-highlighted`). Set the height and `w-auto`. `mark` shows the planet only. The mouth uses a
mask with an id from `useId()`, so many logos can be on one page. The navbar and the sign-in card
use it with `aria-hidden="true"`, because the site name is next to it.

Static files for a site: `/img/pluto.svg` (the logo, black wordmark), `/img/pluto.png` (white
wordmark, for dark backgrounds), `/img/pluto-icon.svg` and `/img/pluto-icon.png` (the planet,
96 px, for a favicon). A site that extends Pluto serves them from the layer's `public/` folder.

## Sidebar icons and footer

Every row of the sidebar has an icon, the children too. `usePlutoAdminNav` gives the "All <type>"
child `lucide:list` and the "New <type>" child `lucide:plus`; a type with no icon in a group gets
`lucide:file`. A layer with its own list and create children uses the same two icons (the posts of
supabase-blog, the products of supabase-shop).

The footer of the sidebar holds the collapse button and a light/dark `UColorModeButton` (hidden when
the color mode is forced; the user menu has the full theme choice). Both have `px-2.5`, so their
icons line up with the menu icons. In the rail they stack with `flex-col-reverse`: the collapse
button stays at the bottom.

The footer has a top border (`border-default`). Collapsed, it is transparent (`in-data-[collapsed=true]`),
not removed, so the footer keeps its height.

The body of the sidebar does not scroll (`ui.body`: `overflow-hidden p-0`). `PlutoAdminSidebarScroll`
does: a Reka UI `ScrollArea` (`type="hover"`, 1s hide delay) with the padding of the old body
(`px-4 py-2`), a light thumb for the dark sidebar, and a 10px scrollbar over the 16px right padding
(the gutter), so the rows never move and the bar never covers them. The scrollbar is `force-mount`
so its opacity fades (`duration-300!` against the no-transition rule). The viewport child is
`block`, not Reka's `display: table`, so a long label truncates.

## The "+" in the sidebar

`PlutoAdminNavMenu` wraps `UNavigationMenu` (the sidebar and the small-screen slideover use it). Each
content type item (a top-level type item, and each child of a group item) carries `newTo` and
`newLabel` ("New <type>") from `usePlutoAdminNav`, only when the user may write the type. The item
has a small "+" `UButton` (`square`, `xs`, ghost, neutral, `aria-label` and title "New <type>") at the
right end. It goes to the new page with `navigateTo`. The collapsed rail shows no "+".

A menu item is a link or an accordion button. A link cannot hold a button (invalid HTML), and Nuxt UI
has no slot outside the link. So `PlutoAdminNavNew` renders in the `item-trailing` slot only an empty
spacer (it keeps room at the right end of the row). On mount it adds a host `<div>` right after the
item link, in the same `<li>`, and teleports the button there. The button is a sibling of the link,
after it in the tab order, and a click on it does not reach the link. The `item` and `childItem`
classes are `relative` for this. The host is positioned on the first row of the item (34 px high),
and left of the chevron when the item has children.

The button is always in the tab order and shows on hover of the link or the button, and on focus of
either (`focus-visible` of the link, `focus-within` of the host). It is not hidden with `tabindex`,
because a changing tab order is hard to follow. Focus reveals it. The slot replaces the default
trailing content, so the component draws the chevron of a group again.

## Focus rings in the bar

The ring of a bar control must not be clipped. The list of actions sits in a wrapper with
`overflow-hidden`. The wrapper has `px-1 -mx-1`, so the ring of the first and the last action has
room. The logo link has its own inset ring (`focus-visible:-outline-offset-2`), because it fills the
full height of the bar.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.