Add Styled Components to a Next.JS Project
lessonDuration 2m 23sFree
Next.JS works with any CSS-in-JS solution, including Styled Components. But to get it working with Next.JS's server-side rendering, you'll need to do some configuration. In this lesson I go through the steps required to get it working properly, including adding `babel-plugin-styled-components` to your project and overriding the `Document` page to inject your styles into the `<Head>` of the page. For reference, please see Styled Components' [guide to SSR](https://www.styled-components.com/docs/advanced#server-side-rendering), and the Next.JS [sample repository for Styled Components](https://github.com/zeit/next.js/tree/master/examples/with-styled-components).