Framework Integration
Integrating with Next.js & Vite
antd-dynamic-ui is isomorphic and runs smoothly on both SSR/SSG environments and client-only Single Page Applications.
Next.js 14 / 15 (App Router)
To prevent Flash of Unstyled Content (FOUC) and ensure Ant Design CSS is extracted during server-side rendering, install @ant-design/nextjs-registry and wrap your Root Layout.
app/layout.tsxtsx
1// app/layout.tsx2import React from "react";3import { AntdRegistry } from "@ant-design/nextjs-registry";4import { ConfigProvider } from "antd";5import { DynamicUIProvider } from "antd-dynamic-ui";6import { useRouter } from "next/navigation";78export default function RootLayout({ children }: { children: React.ReactNode }) {9 const router = useRouter();1011 return (12 <html lang="en">13 <body className="bg-[#fbf8f2] text-[#362117]">14 <AntdRegistry>15 <ConfigProvider16 theme={{17 token: {18 colorPrimary: "#e05d44",19 colorBgBase: "#fbf8f2",20 colorText: "#362117",21 borderRadius: 12,22 },23 }}24 >25 <DynamicUIProvider onNavigate={(url) => router.push(url)}>26 {children}27 </DynamicUIProvider>28 </ConfigProvider>29 </AntdRegistry>30 </body>31 </html>32 );33}
Ensure transpilePackages includes antd-dynamic-ui in your Next.js config:
next.config.mjsjavascript
1// next.config.mjs2/** @type {import('next').NextConfig} */3const nextConfig = {4 transpilePackages: ["antd-dynamic-ui"],5};67export default nextConfig;
Vite / Create React App / React Router SPA
In a client-side SPA, wrap your root with ConfigProvider and provide React Router’s navigate function to DynamicUIProvider so action buttons route without full page reloads.
src/main.tsxtsx
1// src/main.tsx (Vite / React Router)2import React from "react";3import ReactDOM from "react-dom/client";4import { BrowserRouter, useNavigate } from "react-router-dom";5import { ConfigProvider } from "antd";6import { DynamicUIProvider } from "antd-dynamic-ui";7import App from "./App";89function Root() {10 const navigate = useNavigate();1112 return (13 <ConfigProvider14 theme={{15 token: {16 colorPrimary: "#e05d44",17 colorBgBase: "#fbf8f2",18 colorText: "#362117",19 borderRadius: 12,20 },21 }}22 >23 <DynamicUIProvider onNavigate={(url) => navigate(url)}>24 <App />25 </DynamicUIProvider>26 </ConfigProvider>27 );28}2930ReactDOM.createRoot(document.getElementById("root")!).render(31 <React.StrictMode>32 <BrowserRouter>33 <Root />34 </BrowserRouter>35 </React.StrictMode>36);