DEV Community

Rafael Borges
Rafael Borges

Posted on

How to compile styled-components on Next.js

if you are getting problem losing all the style from page, in the moment you render the application.

You just keep next.config.js file as the exemple, adding the code:

  compiler: {
    styledComponents: true,
  },
Enter fullscreen mode Exit fullscreen mode

if you dont have this file on the projet, create it as the exemple.

Structure root folder

Add this code:

const nextConfig = {
  reactStrictMode: true,
  swcMinify: true,
  compiler: {
    styledComponents: true,
  },
}

module.exports = nextConfig
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay