Skip to main content
Next.js has built-in support for Sass after the package is installed. You can use both .scss and .sass syntax.

Installation

Usage with CSS Modules

Use Sass with CSS Modules by creating a file with the .module.scss or .module.sass extension:

Global Sass

Import global .scss or .sass files in your root layout just like global CSS:

Configuring Sass options

To configure the Sass compiler, use sassOptions in next.config.js. You can pass any option supported by the sass package:

Using a custom Sass implementation

You can specify an alternative implementation such as sass-embedded:
next.config.js

Shared variables with CSS Modules

To share Sass variables across all CSS Module files without importing them manually, use the additionalData option:
next.config.js
Then define your shared variables:
styles/variables.scss
Now every CSS Module can use $primary-color and $font-size-base without an explicit @use import.
The .scss (SCSS syntax) and .sass (indented syntax) file extensions are both supported. Choose one based on your team’s preference—SCSS is more common.