Using SCSS with TypeScript & Next.js

Using SCSS with TypeScript & Next.js

When you start using Typescript in the Next.js project using Scss files can be tricky.

Usually, you will get this error: “Cannot find module ‘./styles.m.scss’

scss typescript error

To solve this problem you need to add this code into the file next-env.d.ts.

...
//content of the file

declare module '*.scss' {
const content: any;
export default content;
}

Then everything works as it should

Success scss with typescript

I hope this helped you :)

Get posts on Building SaaS and Interent-Powered Buissness right in your inbox

JourneyLessons and stories from my entrepreneurial journey
AdviceAdvices, stories and interviews from SaaS Founders and Marketers