AdminKitDocs
Getting started

Project structure

The folders of AdminKit for Next.js: App Router routes, components, data, hooks and Sass, and how to add a page with its title and sidebar link.

The free version and AdminKit PRO have the same layout; PRO has more pages, components and plugins in the same folders.

├── public/                 images and other files served as they are
├── scripts/                serve.mjs (npm start) and stats.mjs (npm run stats)
├── src/
│   ├── app/                the routes
│   │   ├── layout.tsx      <html>, the head scripts and the stylesheet
│   │   ├── (dashboard)/    pages with the sidebar, navbar and footer; page.tsx is /
│   │   └── (auth)/         sign-in, sign-up and error pages, centered
│   ├── components/
│   │   ├── bootstrap/      Modal, Dropdown, Offcanvas, ... (see Components)
│   │   ├── plugins/        ChartJs, VectorMap, ... (see Charts)
│   │   ├── navbar/         the top bar and its menus
│   │   ├── sidebar/        the sidebar and its menu
│   │   ├── settings/       the settings panel (PRO)
│   │   ├── ui/             PageTitle, CountUp, Skeleton, Footer
│   │   └── pages/          what one page uses, in pages/<section>/<page>/
│   ├── contexts/           LayoutProvider: the sidebar toggle
│   ├── data/               pages.json, navigation.ts, stats.json and the other app data
│   ├── hooks/              useColorMode, useTheme, useConfig (PRO), ...
│   ├── layouts/            DashboardLayout, AuthLayout and PageEffects
│   ├── lib/                config.ts, head-scripts.ts, site.ts
│   ├── mocks/              the demo data of the pages
│   └── scss/               app.scss and the Sass partials
└── next.config.ts          the static export and BASE_PATH

src/app/ holds only page.tsx and layout.tsx files. The route groups (dashboard) and (auth) pick the layout and are not part of the URL: src/app/(dashboard)/pages-settings/page.tsx is /pages-settings.

Pages

A page is a server component. It exports its metadata and renders Bootstrap markup and components:

src/app/(dashboard)/pages-blank/page.tsx
import { PageTitle } from "@/components/ui/page-title";
import { pageMetadata } from "@/lib/site";

export const metadata = pageMetadata("/pages-blank");

export default function Page() {
  return (
    <>
      <PageTitle title="Blank Page" />

      <div className="row">
        <div className="col-12">
          <div className="card">
            <div className="card-header">
              <h2 className="card-title mb-0">Empty card</h2>
            </div>
            <div className="card-body"></div>
          </div>
        </div>
      </div>
    </>
  );
}

pageMetadata() reads the title and meta description from src/data/pages.json. Put "use client" on the smallest component that needs state, effects or the browser, not on the page. The components in components/bootstrap/ and components/plugins/ are client components already, so a page can render them directly; Tooltip and Popover clone their child element, so use them inside a client component.

Demo data lives in src/mocks/. Replace it with your own data, fetched in the page or in a client component.

Add a page

  1. Create the route, for example src/app/(dashboard)/reports/page.tsx, from the blank page above with pageMetadata("/reports").

  2. Add it to src/data/pages.json:

    {
      "path": "/reports",
      "title": "Reports",
      "layout": "dashboard",
      "description": "Monthly reports."
    }
  3. Link it in the sidebar menu in src/data/navigation.ts (see Sidebar).

  4. Run npm run stats. It updates the counts in src/data/stats.json, and npm run lint fails while a route is missing from pages.json or the counts are out of date.

A page in (auth) gets the centered layout of the sign-in page instead; use "layout": "auth" for it.

Use next/link for links between pages. Images are plain <img> elements with a width and height; write their src with asset() from src/lib/site.ts, so they keep working under a base path:

<img src={asset("/img/avatars/avatar.jpg")} width="40" height="40" alt="" />

Imports

@/ is src/: @/components/bootstrap/modal is src/components/bootstrap/modal.tsx.

Last updated on

On this page