Next.js Discord

Discord Forum

Using CSS modules in global-error

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
I have found a couple threads about this online, but I have yet to find a clear answer in either those threads or the docs. Is it expected that CSS modules do not work in the global-error file? What is the recommended alternative approach for styling that page?

3 Replies

Chum salmon
What's stopping you from using either tailwind or globalsl.css or both to style the page?
HarlequinOP
The error page we're trying to display is built from several other shared UI components, all of which use CSS modules for their styles. We can put the styles specific to this page in global.css easily, but the component styles get messier
HarlequinOP
The question is less around solutions though and more around what the expected behaviour is. The App Router docs for Next 14 say that "CSS Modules can be imported into any file inside the app directory" (https://nextjs.org/docs/14/app/building-your-application/styling/css-modules#example)

The Next 15 docs are a bit less explicit about that but still say "any component inside the app directory" (https://nextjs.org/docs/app/getting-started/css#css-modules)

I can't find anything stating an exception to this for global-error. I'm mainly just looking for confirmation if it's expected these won't work and, if so, some context around why would be awesome if possible