question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

FOUC in Production NextJS apps

See original GitHub issue

What package has an issue

@mantine/core

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:

page_load

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:closed
  • Created a year ago
  • Reactions:4
  • Comments:33 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
klencommented, Jun 5, 2022

Have same problem with next@12.1.6. Downgrading to 12.1.5 solve it. But, upgrading to 12.1.7-canary.29 also did the job.

7reactions
mcamendoza1commented, Jun 2, 2022

Downgrading from next@12.1.6 to 12.1.5 fixed the issue

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found