Skip to content
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

[docs] Add documentation for preventing SSR flicker/FOUC with the Next.js app router #42737

Open
MikeLautensack opened this issue Jun 24, 2024 · 5 comments
Assignees
Labels
customization: theme Centered around the theming features nextjs support: docs-feedback Feedback from documentation page

Comments

@MikeLautensack
Copy link

MikeLautensack commented Jun 24, 2024

Related page

https://mui.com/material-ui/experimental-api/css-theme-variables/usage/

Kind of issue

Missing information

Issue description

The current setup detailed in the docs for Next.js integration https://mui.com/material-ui/integrations/nextjs/ with and without CSS theme variables, fails to fix the SSR flicker/FOUC. The docs seem to suggest CSS theme variables are the solution to the SSR flicker/FOUC in the app router based off of the link above however when you navigate to https://mui.com/material-ui/experimental-api/css-theme-variables/usage/ there is a pages router example and I you cannot use the "getInitColorSchemeScript" in the app router.

Context

No response

Search keywords: SSR flicker/FOUC

Search keywords:

@MikeLautensack MikeLautensack added status: waiting for maintainer These issues haven't been looked at yet by a maintainer support: docs-feedback Feedback from documentation page labels Jun 24, 2024
@arthurbalduini
Copy link
Member

Hello @MikeLautensack, your issue seems to be related to @mui/material and not to this repo @mui/mui-x
I'm moving the issue to the correct repo so the correspondent maintainers can help you! 🙂

@arthurbalduini arthurbalduini transferred this issue from mui/mui-x Jun 24, 2024
@zannager zannager added customization: theme Centered around the theming features nextjs labels Jun 24, 2024
@siriwatknp siriwatknp changed the title Please add documentation for preventing SSR flicker/FOUC with the Next.js app router [docs] [docs] Add documentation for preventing SSR flicker/FOUC with the Next.js app router Jun 26, 2024
@siriwatknp
Copy link
Member

@MikeLautensack In the next version of Material UI v6, you can replace the getInitColorSchemeScript with InitColorSchemeScript component. For more detail, check out the documentation page.

@MikeLautensack
Copy link
Author

@MikeLautensack In the next version of Material UI v6, you can replace the getInitColorSchemeScript with InitColorSchemeScript component. For more detail, check out the documentation page.

Great news! I was on the v5 docs. I appreciate the help!

@github-actions github-actions bot removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jun 26, 2024
@MikeLautensack
Copy link
Author

@MikeLautensack In the next version of Material UI v6, you can replace the getInitColorSchemeScript with InitColorSchemeScript component. For more detail, check out the documentation page.

I seem to be encountering an issue where the InitColorSchemeScript comp and the extend theme api are failing to build on vercel while building successfully on my local machine.

image

image

@MikeLautensack
Copy link
Author

MikeLautensack commented Jul 19, 2024

UPDATE: It is also failing locally now

image

Here are the relavant deps

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customization: theme Centered around the theming features nextjs support: docs-feedback Feedback from documentation page
Projects
None yet
Development

No branches or pull requests

4 participants