Next.js integration
Configuration
Inside app/layout.tsx, import the AppRouterCacheProvider and wrap all elements under the <body> with it:
Custom cache (optional)
Use the options prop to override the default cache options—for example, the code snippet below shows how to change the CSS key to css (the default is mui):
Font optimization
To integrate Next.js font optimization with Material UI, create a new file with the 'use client'; directive. Then create a theme using var(-font-roboto) as a value for the typography.fontFamily field.
Finally, in src/app/layout.tsx, pass the theme to the ThemeProvider:
To learn more about theming, check out the theming guide page.
CSS theme variables
To use CSS theme variables, enable the cssVariables flag:
Learn more about the advantages of CSS theme variables and how to prevent SSR flickering.
Using other styling solutions
If you are using a styling solution other than Emotion to customize Material UI components, set enableCssLayer: true in the options prop:
This option ensures that the styles generated by Material UI will be wrapped in a CSS @layer mui rule, which is overridden by anonymous layer styles when using Material UI with CSS Modules, Tailwind CSS, or even plain CSS without using @layer.
To learn more about it, see the MDN CSS layer documentation.
Next.js v16 Client Component restriction
If you encounter Functions cannot be passed directly to Client Components error from passing Next.js Link to Material UI component prop, you need to create a wrapper component with use client directive like the following:
Then, replace the Next.js Link with the wrapper component:
URL-driven UI and the Suspense boundary
When client components use Next.js App Router hooks that read the URL—for example useSearchParams() from next/navigation for filters, tabs, or pagination—Next.js expects a <Suspense> boundary around that part of the React tree. Without it, you may see build failures or runtime messages about a missing Suspense boundary (behavior depends on your Next.js version and static vs dynamic rendering).
This pattern is common with Material UI: Table, Tabs, TextField, and other controls are often implemented as client components that sync to the query string.
Recommended structure: keep page.tsx as a server component when possible, and wrap only the client subtree that calls useSearchParams in <Suspense>.
Avoid fallback={null} (or an empty fallback) for UI that reserves space in the layout (toolbars, filters, tab bars, and similar). The server and the initial streamed HTML then omit that subtree, and the real content appears only after the client hydrates, which often causes layout shift and hurts CLS. Prefer a fallback whose size and structure approximate the final UI, for example Material UI Skeleton inside Stack or Box with the same minHeight, flex direction, and breakpoints as the loaded component.
OrdersToolbar would be a file marked with 'use client' that calls useSearchParams() and renders Material UI components. Adjust the fallback's layout and Skeleton sizes so they match your real toolbar (or filter row) as closely as possible.
For details and version-specific notes, see the Next.js documentation for useSearchParams.
Pages Router
This section walks through the Material UI integration with the Next.js Pages Router, for both Server-side Rendering (SSR) and Static Site Generation (SSG).
Installing the dependencies
Start by ensuring that you already have @mui/material and next installed. Then, run one of the following commands to install the dependencies:
Go HomePage: Sách Hay 24H hoặc click: Sách hay nhất mọi thời đại, Mua sách online, Bạn đắt giá bao nhiêu, Truyện cổ tích Việt Nam, Mùa xuân nho nhỏ, Tràng giang, Hịch tướng sĩ
Nghệ thuật nói chuyện – Yếu tố giúp bạn thành công
Nghệ thuật nói chuyện – Yếu tố giúp bạn thành công
Lưu ngay bộ meme face siêu hài để làm giàu kho ảnh vui nhộn
Lưu ngay bộ meme face siêu hài để làm giàu kho ảnh vui nhộn
Hình ảnh Anime Chibi - Tổng hợp hình ảnh Anime Chibi đẹp và dễ thương nhất
Hình ảnh Anime Chibi - Tổng hợp hình ảnh Anime Chibi đẹp và dễ thương nhất
Tổng hợp các công nghệ hình ảnh nổi bật nhất trên tivi Samsung
Tổng hợp các công nghệ hình ảnh nổi bật nhất trên tivi Samsung
Nguồn gốc những meme ghép chúa hề nổi tiếng MXH, từ “cô gái chửi con mèo” đến “người mẹ và đứa con”
Nguồn gốc những meme ghép chúa hề nổi tiếng MXH, từ “cô gái chửi con mèo” đến “người mẹ và...
Trình Chiếu PowerPoint Không Full Màn Hình: Nguyên Nhân & Cách Khắc Phục
Trình Chiếu PowerPoint Không Full Màn Hình: Nguyên Nhân & Cách Khắc Phục
Tổng Bí thư Tô Lâm: Với Việt Nam, phát triển nhanh và bền vững là một thực thể thống nhất
Tổng Bí thư Tô Lâm: Với Việt Nam, phát triển nhanh và bền vững là một thực thể thống nhất
Tiệm ảnh Beauty - 2T Concept - Gói chụp cổ phục tại chùa Thắng Nghiêm
Tiệm ảnh Beauty - 2T Concept - Gói chụp cổ phục tại chùa Thắng Nghiêm
Hướng Dẫn Cách Chụp Ảnh Ngầu Cho Nữ Kiếm Triệu Like
Hướng Dẫn Cách Chụp Ảnh Ngầu Cho Nữ Kiếm Triệu Like
Review xem nhiều
Review mới nhất













