Skip to content

Next.js & Nuxt ​

Both starter kits render on the server and let the runtime enhance the result in the browser. AdminVora needs no props, provider or plugin registration — it reads the markup — so a page rendered on the server, streamed, or produced by a client component is enhanced the same way.

bash
npm run build:dist
npm run create -- my-admin --kit=nextjs     # or --kit=nuxt
cd my-admin
npm install
npm run dev        # http://localhost:3000

The two SSR problems ​

Theme flash. The theme is attributes on <html>, restored from localStorage by an inline boot script before the first paint. Neither framework's script loaders run early enough, so the boot script is a literal inline <script> in the document head.

Hydration mismatches. The boot script rewrites <html> attributes before the framework hydrates, and the runtime rewrites some text (money, relative times). So the runtime loads after hydration, and <html> tells the framework its attribute mismatch is deliberate.


Next.js (App Router) ​

app/
├── layout.jsx                the shell — boot script, asset links, runtime
├── page.jsx, orders/page.jsx, settings/page.jsx
components/
├── AppSidebar.jsx            'use client' — needs usePathname
├── AppTopbar.jsx, AppFooter.jsx   server components, ship no JavaScript
└── RescanOnNavigate.jsx      'use client' — the re-scan
public/assets/adminvora/      the compiled bundle

Root layout ​

jsx
// app/layout.jsx
import Script from 'next/script';
import RescanOnNavigate from '../components/RescanOnNavigate.jsx';

const BOOT = `/* the inline boot script, copied from the kit */`;

export default function RootLayout({ children }) {
  return (
    <html lang="en" data-bs-theme="light" data-av-preset="aurora" suppressHydrationWarning>
      <head>
        <script dangerouslySetInnerHTML={{ __html: BOOT }} />
        <link rel="stylesheet" href="/assets/adminvora/css/adminvora.min.css" />
      </head>
      <body>
        {children}
        <Script src="/assets/adminvora/js/adminvora.js" strategy="afterInteractive" />
        <RescanOnNavigate />
      </body>
    </html>
  );
}

dangerouslySetInnerHTML inserts a constant here, never user input. suppressHydrationWarning covers that element's attributes only, not the tree beneath it.

Re-scan on navigation ​

jsx
// components/RescanOnNavigate.jsx
'use client';
import { useEffect } from 'react';
import { usePathname } from 'next/navigation';

export default function RescanOnNavigate() {
  const pathname = usePathname();
  useEffect(() => { window.AdminVora?.init(); }, [pathname]);
  return null;
}

AdminVora.init() skips every element it already owns, so calling it after each navigation is safe. It is a tiny client component so the layout itself can stay on the server.

CSP nonce ​

Read the nonce your middleware sets and put it on the inline boot script:

jsx
import { headers } from 'next/headers';

const nonce = (await headers()).get('x-nonce');
<script nonce={nonce} dangerouslySetInnerHTML={{ __html: BOOT }} />

Nuxt 4 ​

nuxt.config.ts                head — boot script, asset links, runtime
app/
├── app.vue                   the shell
├── components/               AppSidebar, AppTopbar, AppFooter (auto-imported)
├── pages/                    index, orders, settings
└── plugins/adminvora.client.js   the re-scan on navigation
public/assets/adminvora/      the compiled bundle
ts
// nuxt.config.ts
const BOOT = `/* the inline boot script, copied from the kit */`;

export default defineNuxtConfig({
  app: {
    head: {
      htmlAttrs: { lang: 'en', 'data-bs-theme': 'light', 'data-av-preset': 'aurora' },
      link: [{ rel: 'stylesheet', href: '/assets/adminvora/css/adminvora.min.css' }],
      script: [
        { innerHTML: BOOT, tagPosition: 'head', tagPriority: 'critical' },
        { src: '/assets/adminvora/js/adminvora.js', defer: true, tagPosition: 'bodyClose' }
      ]
    }
  }
});

tagPriority: 'critical' keeps the boot script ahead of the stylesheet and Nuxt's own entry. The runtime loads at bodyClose, after Vue has hydrated.

Re-scan on navigation ​

js
// app/plugins/adminvora.client.js
export default defineNuxtPlugin(() => {
  useRouter().afterEach(() => {
    requestAnimationFrame(() => window.AdminVora?.init());
  });
});

afterEach fires before Vue has patched the DOM, so wait a frame — otherwise the scan wires the outgoing page. .client keeps the plugin out of the server bundle.


Leave enhanced markup uncontrolled ​

The data grid owns row visibility and the validator owns input validity. Mirroring either in React or Vue state gives one element two owners. Before removing a subtree that holds vendor widgets, call AdminVora.destroy(el).

Checklist ​

  • [ ] Boot script inline in <head>, before the stylesheet, with a nonce under CSP
  • [ ] <html> suppresses its attribute hydration warning (Next.js)
  • [ ] Runtime loads after hydration (afterInteractive / bodyClose)
  • [ ] AdminVora.init() after every client-side navigation
  • [ ] Enhanced markup is not controlled by framework state

Read next: Accessibility.

Documentation for @creativeigniter/adminvora