Introducing a new way to review your PRs.

Read the announcement

arhamkhnz / next-shadcn-admin-dashboard

Modern Admin Dashboard Template built with Shadcn UI and Next.js 16

View on GitHub

22 documents · Updated Nov 23, 2026

docs / shared-application-services

Shared application services

Shared application services give the UI common rules for product identity, navigation, demo data, display values, preferences, browser state, fonts, icons, and cookie access. They connect page-level experiences to the root layout and dashboard shell without owning a business workflow. See Shared configuration and utilities for the related lower-level service view.

Application identity

Application metadata

The application configuration defines the product identity used across the UI. The root layout uses it for document metadata, while authentication screens use the product name for visible branding. This keeps the main entry points aligned while shared release and project data remains available to other UI surfaces.

References: src/…/app-config.ts• L1-16 src/…/layout.tsx• L15-30 src/…/layout.tsx• L6-16

Application icons

The application icon service turns the shared product logo into black square image responses for browser and device icon entry points. It keeps the centered logo and its size rule in one place so the browser icon and Apple touch icon present the same product identity at their requested sizes.

References: src/…/app-icon.tsx• L1-24 src/…/icon.tsx• L1-17 src/…/apple-icon.tsx• L1-10 src/…/app-logo.tsx• L3-21

The sidebar navigation model turns the dashboard into labeled groups of destinations. The groups cover dashboard views, shared pages, legacy routes, and destinations that are not yet available. Each destination can be a direct link or a parent with child links, and the model carries user-facing state such as icons, badges, disabled status, and whether a destination opens in a new tab.

The dashboard sidebar reads this model to show active paths and choose the right interaction for the current sidebar state. A parent opens when one of its child paths matches the current URL. One navigation definition can therefore serve expanded, collapsed, and mobile views.

References: src/…/sidebar-items.ts• L34-70 src/…/sidebar-items.ts• L72-300 src/…/nav-main.tsx• L85-175

Shared UI data

Demo user data

The shared user data provides the account records used by the dashboard shell and account controls. It supports account switching and user display without making those UI areas depend on a live user service.

The first record acts as the root user for the sidebar account display. Pages that need separate table data can define their own view data, so this shared data stays focused on shell identity and switching.

References: src/…/users.ts• L1-20 src/…/layout.tsx• L8-10 src/…/layout.tsx• L62-67 src/…/app-sidebar.tsx• L17-18

Display helpers

Shared display helpers turn common values into stable UI labels. They provide fallback initials for names and locale-aware currency text for account, finance, invoice, and other views. These rules keep repeated displays consistent across workspaces.

References: src/…/utils.ts• L1-35

Preference services

Preference registry

The preference registry gives UI settings one contract for allowed values, defaults, document attributes, and persistence. It covers theme mode, theme preset, font, content layout, navbar style, and sidebar shape. It also marks shell settings that must be available during server rendering.

The preference store uses this contract to apply a change to the document, update in-memory state, and save the value through the selected persistence path. Invalid stored values fall back to the registered default. For a focused view of this contract and its helpers, read Shared configuration and utilities.

References: src/…/preferences-config.ts• L1-12 src/…/preferences-config.ts• L24-37 src/…/preferences-config.ts• L55-120 src/…/preferences-config.ts• L122-134 src/…/preferences-store.ts• L21-61

Browser persistence

Browser persistence keeps user choices available after a page change or reload when the setting does not need server-rendered state. The client cookie service supports short-lived browser cookies, and the local storage service provides a best-effort client-only store. Storage errors do not stop the UI from using its current in-memory value.

Preference persistence selects the browser cookie, server cookie, local storage, or no-save path from the registry. This lets the UI change a setting through one store API while the storage method matches the setting’s needs.

References: src/…/cookie.client.ts• L1-24 src/…/local-storage.client.ts• L1-19 src/…/preferences-storage.ts• L14-35 src/…/preferences-store.ts• L32-44

The server action boundary provides the server-side path for reading and writing cookies. It also reads registered preferences on the server and returns a validated value or its default. This lets server-rendered layouts use preference state without accessing browser APIs.

The dashboard layout uses this boundary to read sidebar shape before it builds the shell. Client preference changes can call the same boundary when a setting uses server-cookie persistence. The boundary connects client controls and server-rendered layout state through one preference contract.

References: src/…/server-actions.ts• L1-40 src/…/layout.tsx• L18-35 src/…/preferences-storage.ts• L14-30

Font registry

The font registry gives the UI one list of selectable font families and the labels shown in font controls. It also exposes the font variables needed by the root layout, so the selected font can be applied through the same preference system.

The root layout loads the registry’s font variables for the document. Layout controls use the registry’s options for selection, while the preference registry limits saved font values to known keys. The registry now includes sans, serif, mono, and pixel-style choices, which keeps the picker, document styles, and saved values aligned.

References: src/…/registry.ts• L1-21 src/…/registry.ts• L111-200 src/…/layout.tsx• L8-12 src/…/layout.tsx• L32-66 src/…/layout-controls.tsx• L11-12 src/…/layout-controls.tsx• L108-120

Preference lifecycle

The preference lifecycle moves a setting from a registered default or stored cookie into the document and the client store. This diagram shows the shared relationship between the root boot step, server-rendered dashboard state, and later client changes.

flowchart LR
    R[Preference registry] --> D[Defaults and allowed values]
    D --> B[Root document boot]
    C[Stored cookie] --> V[Server validation]
    V --> S[Dashboard shell]
    B --> S
    U[UI control] --> P[Preference store]
    P --> A[Document attributes]
    P --> W[Selected persistence path]
    W --> C

Preference synchronization

The root document starts with safe defaults, and the boot step can restore saved theme and layout choices before the UI settles. The dashboard then reads server-safe sidebar values so its first render matches the saved shell shape. Client controls update the document and store at once, then persist the new value without changing the control API.

References: src/…/layout.tsx• L21-45 src/…/theme-boot.tsx• L1-47 src/…/server-actions.ts• L30-40 src/…/preferences-store.ts• L27-60

Change checklist

When these files or sections are changed, remember to consider these:

  • Add or change a sidebar destination with its route, parent grouping, active-path behavior, and new-tab or disabled state in src/…/sidebar-items.ts and src/…/nav-main.tsx.
  • Add or change a preference with its allowed values, default, document attribute, persistence mode, server-rendering needs, and boot behavior across the preference registry, store, and server boundary.
  • Add or rename a font key in the registry together with its selectable label, document variable, and saved preference value.
  • Change the shared logo or icon size rule with both browser icon entry points and the visible application logo in mind.
  • Change application identity fields with the root metadata and authentication shell uses in mind.
  • Change shell-level demo users with both the account switcher and root sidebar user display in mind.
  • Change shared display rules with avatar fallbacks and currency displays in mind, including callers that pass a locale, currency, or no-decimal setting.

Important failure modes

TriggerConsequenceGuard
A sidebar item points to a route that is absent or changes without a matching navigation updateThe user sees a dead destination or the wrong active groupKeep the navigation URL and route contract aligned, including child paths used for active matching
A saved preference contains a value outside its registered setThe UI could start with an unsupported theme, layout, or font choiceparsePreference accepts only registered values and otherwise returns the preference default
A server-rendered sidebar preference uses a browser-only persistence pathThe first dashboard render can disagree with the saved shell stateKeep layout-critical preferences on cookie-backed persistence rather than local storage
Browser storage is blocked or unavailableA new client-only choice is not retained after reloadTreat storage as best effort and rely on the active in-memory preference value
A font key is removed from the registry while saved values or controls still refer to itThe font picker and restored document state can lose their shared contractUse registry-derived keys and options, then update all saved-value consumers with the registry change
The shared logo or icon sizing rule changes in only one entry pointBrowser and device icons can show different branding or crop the logoRoute both icon entry points through the shared icon service and keep it aligned with AppLogo
A shared display helper receives an unsupported value or a mismatched currency or localeAvatars can lose a useful fallback or money labels can show the wrong formatPreserve the helper fallbacks and pass explicit formatting options when a view uses a non-default currency or locale

Key files

FileWhy to read it
src/…/app-config.tsDefines the shared product identity, release data, and project links used by the UI.
src/…/app-icon.tsxDefines the common browser and device icon response.
src/…/sidebar-items.tsDefines the dashboard destination groups and navigation state.
src/…/nav-main.tsxShows how the navigation model becomes active links and submenus.
src/…/users.tsDefines the shell-level demo accounts used by dashboard identity controls.
src/…/utils.tsDefines shared name fallback and currency display rules used across UI views.
src/…/preferences-config.tsDefines the common preference contract, defaults, and persistence choices.
src/…/preferences-storage.tsConnects preference changes to their selected storage path.
src/…/server-actions.tsDefines the server boundary for cookie-backed preference state.
src/…/registry.tsDefines selectable fonts and the document variables used by the UI.
src/…/layout.tsxShows how shared identity, fonts, defaults, and preference boot support the whole app.
src/…/layout.tsxShows how server preference state and shared users support the dashboard shell.