AdminShell
Canonical app shell — ModernSidebar + Cmd+K CommandPalette + ResponsiveBreadcrumb
AdminShell is the canonical shell for TelamonJS applications. It composes
ModernSidebar + CommandPalette (Cmd+K) + ResponsiveBreadcrumb + header actions into a
single client component.
Basic Usage
Fetch the session on the server, pass it down to a small 'use client' wrapper that renders
AdminShell. Menu icons are passed as strings, resolved internally via getIcon — never
import the Lucide component directly in the menu config.
'use client'
import { AdminShell, Toaster } from '@telamonjs/ui'
import { useRouter } from 'next/navigation'
import { menuConfig } from '@/config/menu'
export function LayoutProviders({ children, session }) {
const router = useRouter()
return (
<>
<AdminShell
menuConfig={menuConfig}
session={session ?? undefined}
systemName='My App'
logoUrl='/logo.png'
onSignOut={() => router.push('/sign-out')}
>
{children}
</AdminShell>
<Toaster />
</>
)
}import { auth } from '@/lib/auth'
import { LayoutProviders } from '@/components/providers/LayoutProviders'
export default async function AdminLayout({ children }) {
const session = await auth()
return <LayoutProviders session={session}>{children}</LayoutProviders>
}import type { MenuItem } from '@telamonjs/ui'
export const menuConfig: MenuItem[] = [
{ id: 'dashboard', type: 'single', title: 'Dashboard', href: '/admin', icon: 'LayoutDashboard' },
{
id: 'admin-group',
type: 'group',
title: 'Administration',
icon: 'Settings',
children: [
{ id: 'users', type: 'single', title: 'Users', href: '/admin/users', icon: 'Users' },
],
},
]Filtering by permission
Give a menu item a permission (a string, or an array where any of them grants, the same rule as
a CrudConfig action's permission) and pass AdminShell a can checker. The sidebar and the
Cmd+K palette then show only the items can grants. Items without a permission always show.
Without the prop, the can of a PermissionsProvider
above the shell filters instead, so one checker gates the menu and every list.
// src/config/menu.ts
{ id: 'users', type: 'single', title: 'Users', href: '/admin/users', permission: 'users.read' }
// LayoutProviders.tsx, with @telamonjs/permissions
<AdminShell menuConfig={menuConfig} can={perm => checker.can(session.user, perm)}>- A group whose own
permissionis denied goes with its children. A group whose children are all denied goes too, unless it has its ownhref(then it stays as a link). - Separators left at the start, at the end or doubled by the filtering are dropped.
- The breadcrumb keeps labeling routes from the full menu: a user can still land on a page by link.
For a menu rendered outside AdminShell, the same rule is exported as a pure function,
filterMenuByPermission(menu, can), which returns a new array and leaves the input untouched.
Import it, and the menu types, from @telamonjs/ui/menu in plain modules such as a menu config
under src/lib and its unit tests: that entry has no React or Next.js import, while the root
barrel pulls in next/navigation.
Hiding a menu item is not access control. The page and the API behind it must check the permission themselves.
Props
Prop
Type
MenuItem.icon accepts string | IconComponent — prefer string and register icons via the
project's iconRegistry (see Provider Setup Pattern).
Full interface
interface AdminShellProps {
children: React.ReactNode
menuConfig: MenuItem[]
can?: (permission: string) => boolean
session?: ModernSidebarProps['session']
systemName?: string
logoUrl?: string
compactLogoUrl?: string
logoHeight?: number | string
logoMaxWidth?: number | string
compactLogoHeight?: number | string
compactLogoMaxWidth?: number | string
onSignOut?: () => void
onStopImpersonation?: () => Promise<void>
showImpersonationBanner?: boolean // default false
localeSwitcher?: boolean // default true
profileHref?: string
headerActions?: React.ReactNode
themeToggle?: boolean // default false
commandActions?: CommandPaletteItem[]
breadcrumbProps?: AdminShellBreadcrumbProps
className?: string
contentClassName?: string
}What it composes
ModernSidebar— compact/expanded sidebar + mobile drawer, hierarchical menu, avatar/role, impersonation banner.CommandPalette— Cmd+K palette, items auto-generated frommenuConfigpluscommandActions.ResponsiveBreadcrumb— auto-detects the current route.
Dashboards with tabs
For an internal page with multiple views (not the top-level shell), use ShellPage +
AdminHeader + AdminTabs + useTabUrlSync instead of a standalone page per module:
'use client'
import { ShellPage, AdminHeader, AdminTabs, useTabUrlSync, type TabItem } from '@telamonjs/ui'
const TAB_VALUES = ['overview', 'details'] as const
const tabs: TabItem[] = [
{ value: 'overview', label: 'Overview', content: <OverviewTab /> },
{ value: 'details', label: 'Details', content: <DetailsTab /> },
]
export default function DashboardPage() {
const { activeTab, setTab } = useTabUrlSync({ tabs: TAB_VALUES })
return (
<ShellPage>
<AdminHeader title='Dashboard' />
<AdminTabs tabs={tabs} value={activeTab} onValueChange={setTab} />
</ShellPage>
)
}Each tab that lists a CRUD module renders <ListPage config={config} embedded />.
See Also
- ModernSidebar - Sidebar composed by
AdminShell - Provider Setup Pattern - Full provider hierarchy
- Theming - Tokens the shell uses, dark mode and
ThemeToggle - AppShell - Flexible primitive shell for non-standard layouts