Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
Why is a statically generated page unstyled when sent to the client?

When running the Next.js official boilerplate npx create-next-app and previewing it in the browser, I noticed the statically generated html document isn't styled:

enter image description here

I believe this could lead to FOUC problems. How can I make sure that the page is already styled when served to the client, as in the case of Next.js' official site:

enter image description here

Note: I just created a boilerplate project using npx create-next-app and did not modify any code. I am using Next.js v12.0.7 and React v17.0.2.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To get the response similar to Next.js' website, you need to inline critical CSS. This is (still) experimental in next@12.0.7 (and undocumented). To enable it modify your next.config.js:

module.exports = {
  experimental: { optimizeCss: true }
}

You need to install critters (yarn add -D critters or npm i -D critters) for this to work. Also, you need to run production build (next build && next start) not a dev one like you're doing in that image you have shared.

Result:

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda