Skip to content

Problems with the CLS value at Lighthouse test #852

Answered by onemanwenttomow
Miningmark asked this question in Web
Discussion options

You must be logged in to vote

Hi @Miningmark,

The issue seems to be that the CSS is only rendering on the client. (If you watch closely on the page you will see a "flash", or if you look at the snapshots in the google lighthouse report you can also sometimes see it).

A possible solution would be to use ServerStyleSheet.

Here is some boiler-plate (that we use in our other recap projects) that you could tailor to your needs (for _document.js)

import Document, { Html, Head, Main, NextScript } from "next/document";
import { ServerStyleSheet } from "styled-components";

export default class MyDocument extends Document {
  static async getInitialProps(ctx) {
    const sheet = new ServerStyleSheet();
    const originalRender…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Miningmark
Comment options

Answer selected by ahohnsen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Web
Labels
None yet
2 participants