FOUC in Production NextJS apps
See original GitHub issueWhat package has an issue
Note: This issue only occurs in a production nextjs build. It is not noticeable while running the app in development
Describe the bug
Hello! I’ve noticed a quick jerk/blink that seems to happen before styles load. (See the gif below for visual). I’m not sure what’s causing this behavior, but I wanted to know if I was doing something wrong in my implementation.
I’m currently using vercel to deploy the site and using domain forwarding. Could this be the culprit?
Thanks for any help!
Here is my _document
file:
import Document, {
Html, Head, Main, NextScript,
} from 'next/document';
import {createGetInitialProps} from '@mantine/next';
const getInitialProps = createGetInitialProps();
export default class _Document extends Document {
static getInitialProps = getInitialProps;
render() {
return (
<Html lang="en">
<Head>
<link rel="shortcut icon" href="/static/favicon.ico" />
</Head>
<body className="light">
<Main />
<NextScript />
</body>
</Html>
);
}
}
And the _app
file:
import Head from 'next/head';
import {AppProps} from 'next/app';
import {MantineProvider} from '@mantine/core';
import {SubscribeContextProvider} from '../contexts/SubscribeContext';
import {FeedbackContextProvider} from '../contexts/FeedbackContext';
import Navigation from '../components/Navigation';
import Footer from '../components/Footer';
const App = ({Component, pageProps}: AppProps) => (
<>
<Head>
<title>Melo</title>
</Head>
<MantineProvider
withGlobalStyles
withNormalizeCSS
theme={{
colorScheme: 'light',
}}
>
<SubscribeContextProvider>
<FeedbackContextProvider>
<Navigation />
<Component {...pageProps} />
<Footer />
</FeedbackContextProvider>
</SubscribeContextProvider>
</MantineProvider>
</>
);
export default App;
Here is a gif showing the behavior:
In which browser did the problem occur
chrome
If possible, please include a link to a codesandbox with the reproduced problem
No response
Do you know how to fix the issue
No
Are you willing to participate in fixing this issue and create a pull request with the fix
Yes
Possible fix
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:33 (7 by maintainers)
Top Results From Across the Web
FOUC using new Next.js 10 and React 17 #18769 - GitHub
We're seeing it in production. Have hacked around it by disabling visibility until the app is fully mounted.
Read more >NextJS F.O.U.C : r/nextjs - Reddit
The FOUC only occurs in production (I'm deploying via Vercel). I've read threads about people having the same problem but with frameworks ...
Read more >How to stop FOUC and CSS transitions firing on page load in ...
But as I went to launch and test a production build I noticed a nasty FOUC (flash of unstyled content) on first load...
Read more >Flash of Unstyled Content (FOUC) for Nextjs using Mantine
This bug is only in production, in development it works fine. Example: https://gotrip.vercel.app If you don't see the flash, copy the link and ......
Read more >Solve flash of unstyled content (FOUC) on NexJS and GatsbyJS
This guide will help you solve the issue known as “flash of unstyled content” (FOUC) on your Nextjs or Gatbsyjs site that was...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have same problem with
next@12.1.6
. Downgrading to12.1.5
solve it. But, upgrading to12.1.7-canary.29
also did the job.Downgrading from next@12.1.6 to 12.1.5 fixed the issue