Skip to content

[docs] Next.js integration improvements #45922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
mnajdova opened this issue Apr 15, 2025 · 0 comments · May be fixed by #45946
Open

[docs] Next.js integration improvements #45922

mnajdova opened this issue Apr 15, 2025 · 0 comments · May be fixed by #45946
Assignees
Labels
docs Improvements or additions to the documentation nextjs

Comments

@mnajdova
Copy link
Member

mnajdova commented Apr 15, 2025

Steps to reproduce

Following https://mui.com/material-ui/integrations/nextjs/#pages-router using the create-next-app@latest you will get the following bugs/confusions:

  • when adding the props param in the MyDocument component it throws a TS error that props is any
  • following adding the in the _app.tsx file is not intuitive, as the code snippet is not using the default generated template, is not intuitive what props should be forwarded to the vs to the . The initial code looks like this:
    import "@/styles/globals.css";
    import type { AppProps } from "next/app";
    
    export default function App({ Component, pageProps }: AppProps) {
      return <Component {...pageProps} />;
    }
    
  • on the Cascade layers (optional) section, there are TS issues when copying the code, e.g. ctx should have the DocumentContext type set
  • the pages/_app.tsx codesnippet is missing the line for defining the clientCache variable
    const clientCache = createEmotionCache({ enableCssLayer: true });
    

Current behavior

No response

Expected behavior

No response

Context

No response

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: next.js, docs

@mnajdova mnajdova added status: waiting for maintainer These issues haven't been looked at yet by a maintainer docs Improvements or additions to the documentation nextjs labels Apr 15, 2025
@siriwatknp siriwatknp removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Apr 18, 2025
@siriwatknp siriwatknp linked a pull request Apr 18, 2025 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation nextjs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants