---
title: "Add your own admin tabs"
description: "Put the tools your team runs the app with inside the admin console: a page under app/pages/admin/ becomes a tab beside the built-in ones, guarded like the console, hidden from everyone else, and backed by admin-tier functions."
canonical_url: "https://nuxt-backend.dev/docs/build/auth/admin/custom-tabs"
---
# Add your own admin tabs

> Put the tools your team runs the app with inside the admin console: a page under app/pages/admin/ becomes a tab beside the built-in ones, guarded like the console, hidden from everyone else, and backed by admin-tier functions.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/runtime/vue/components/admin/admin-tabs.ts)

Every app grows tools only its team uses: a queue of strips to feature, a switch for a seasonal contest, a list of reports to answer. Put them in the admin console rather than in a second admin app. A page you add under `app/pages/admin/` becomes a tab of the console, in its frame, beside Users, Workspaces and the rest.

This is plain Nuxt routing: the console is a parent route, and your page is its child. The package adds the tab bar entry, the console's guard, and the 404 that keeps the page private.

## Add a tab

Create the page, and name its tab in `definePageMeta`:

```vue [app/pages/admin/featured.vue]
<script setup lang="ts">
import { api } from '#backend/api'

definePageMeta({
  auth: { role: 'admin', hidden: true },
  adminTab: { label: 'Featured', icon: 'i-lucide-star' },
})

const strips = useQuery(api.featured.candidates, {})
const feature = useMutation(api.featured.set)
</script>

<template>
  <ul>
    <li v-for="strip in strips.data.value" :key="strip._id">
      {{ strip.title }}
      <button type="button" @click="feature({ stripId: strip._id, featured: true })">Feature {{ strip.title }}</button>
    </li>
  </ul>
</template>
```

- **adminTab** puts the page in the console's tab bar: `label`, an `icon` (a class such as `i-lucide-star`, drawn before the label when your app has an icon set), and `order` to place it among the others. The built-in tabs sit ten apart, from 10 to 170 (Users, Workspaces, Activity, Reports, Flags, Access, Waitlist, Announcements, Inbox, Referrals, Billing, Queue, Costs, Analytics, Webhooks, Suppressions, System), so `order: 25` puts yours after Workspaces. Without an `order` the tab comes last. Its address is the page's own, `/admin/featured`, and the console stays around it.
- **The console's guard holds.** A parent's rules hold for its children, so a page under `/admin` asks for the `admin` role even without its own `auth`. Saying it, as above, keeps the rule visible where you read the page.
- **hidden: true keeps it private.** Anyone else gets a 404, the same as for a page that doesn't exist ([Hide a page from everyone else](https://nuxt-backend.dev/docs/build/auth/access/pages#hide-a-page-from-everyone-else)).
- **Kept out of search.** Every page under `/admin`, like every private page of the package, carries `<meta name="robots" content="noindex, nofollow">` ([Search engines](https://nuxt-backend.dev/docs/build/ui/pages#search-engines)).

## Back it with admin functions

The page decides what the screen shows. The functions it calls protect the data, so build them with the [`admin` tier](https://nuxt-backend.dev/docs/build/auth/access/functions):

```ts [backend/featured.ts]
import { v } from 'convex/values'
import { admin } from './functions'

export const candidates = admin.query({
  args: {},
  handler: async ctx => ctx.db.query('strips')
    .withIndex('publishedAt').order('desc').take(50),
})

export const set = admin.mutation({
  args: { stripId: v.id('strips'), featured: v.boolean() },
  handler: async (ctx, { stripId, featured }) => {
    await ctx.db.patch('strips', stripId, { featured })
  },
})
```

The tier reads the role fresh on every call, refuses an administrator's visit to someone's account on writes, and asks its mutations for a [recent sign-in](https://nuxt-backend.dev/docs/build/auth/access/step-up). A routine write like this one can say `recentSignIn: false`. Record what it changes with [`recordBackendEvent`](https://nuxt-backend.dev/docs/build/auth/admin/audit-log#record-your-own-events), so the Activity tab shows it.

## Use the console's parts

Build the tab from the same parts as the built-in tabs, so it looks like the rest of the console. `<AdminUsers>`, `<AdminWorkspaces>` and `<AuditLog>` work inside it, and `useAdmin()` gives you the accounts for markup of your own ([Run the admin console](https://nuxt-backend.dev/docs/build/auth/admin#your-own-page-useadmin)).

## What happens when…

- **Someone else opens the tab.** A signed-out visitor and a signed-in person without the role get the same 404 as for an address that doesn't exist, because the console and your page say `hidden: true`. The sign-in page never shows that the page is there.
- **The page has no adminTab.** It still works at its address, inside the console and under its guard, but the tab bar doesn't list it and no tab is selected.
- **adminTab has no label, or the page's address has a parameter** (`/admin/reports/[id]`). The tab bar leaves it out, and the build names the page in a warning. Make the list page the tab and let it link to the detail page; the list stays selected while the detail shows.
- **Two tabs share an order.** They sort by label.
- **A function refuses.** The `admin` tier answers [`forbidden`](https://nuxt-backend.dev/docs/reference/backend/errors#forbidden) to a non-administrator and [`reauthentication_required`](https://nuxt-backend.dev/docs/reference/backend/errors#reauthentication_required) to a stale sign-in, as the built-in tabs do.

## Limits

- **Tabs are pages.** Each one is a route of your app, so it ships in your bundle like any other page.
- **The bar wraps** onto another line past what fits, so about ten tabs read well on a phone. Group related tools on one page past that.
- **A page of yours at /admin** (`app/pages/admin.vue` or `admin/index.vue`) replaces the console, and with it the tab bar: the pages below it are yours to frame.
- **Your functions decide what's safe.** The tab only hides the screen. Every function it calls needs the `admin` tier, or a check of its own.

## Test it

```ts [backend/featured.test.ts]
import { asUser, defineBackendTestApp } from 'nuxt-backend/test'
import { expect, test } from 'vitest'
import { api } from './_generated/api'
import schema from './schema'

const testApp = defineBackendTestApp(schema, import.meta.glob('./**/*.ts'))

test('only an administrator lists candidates', async () => {
  const t = testApp()
  const ada = await asUser(t)
  const grace = await asUser(t, { role: 'admin' })
  await expect(ada.query(api.featured.candidates, {})).rejects.toThrow()
  await expect(grace.query(api.featured.candidates, {})).resolves.toEqual([])
})
```

## Related

- [Run the admin console](https://nuxt-backend.dev/docs/build/auth/admin): the built-in tabs.
- [Protect pages and routes](https://nuxt-backend.dev/docs/build/auth/access/pages): `hidden`, and how a parent's rules guard its children.
- [Protect backend functions](https://nuxt-backend.dev/docs/build/auth/access/functions): the `admin` tier.
- [Packaged pages](https://nuxt-backend.dev/docs/build/ui/pages): the console among the pages the module mounts, and how they stay out of search.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
