r/nextjs•
Zagged

Is anyone using Linaria (css-in-js library) with a recent version of Next.js?

Im trying to get it working with Next v12. I got as far as there being no errors, but my page refuses to load

Posted Jul 15, 2022, 3:24 AM UTC

58
irekrog•

https://github.com/callstack/linaria/issues/589 3 days ago someone asked about this, but no response from linaria mainteners. It is sad because Linaria looks very promising, but I can't use it because I work in Next.js projects...

6
ZaggedOP•

Thanks, ill keep an eye on that thread.

What do you use instead?

I'm thinking of using emotion, since i presume it is popular enough to work well with nextjs.

1
irekrog•

I use `styled-components` but I've been doing research about other technologies so thats why I've discovered `linaria` (also other libs like `stitchies`, `vanilla-extract`, `treat`, but I haven't tried it yet).

1
besthelloworld•

It looks incredibly similar to @emotion/react and @emotion/styled which both work with Next including for SSR. What features of Linaria are you missing from those?

1
blukkie•

Linaria doesn’t have JS runtime afaik. Can’t find if emotion has that but that’s mainly the big winner for Linaria, as its compiled to css during build

1
besthelloworld•

Ah okay, that's interesting. But if you use no dynamic styles and SSR with Emotion then it will generally act the same way. But I don't think there's a way to do that with Emotion if you're building an SPA

1
ZaggedOP•

What he said, and also it's for a personal project so I'd rather not use emotion since I use it at work. Also, I really like the fact that it generates classNames that u can actually re-use in your code e.g.

const thing = css` ... `;

<div className={css` .${thing} { ... } `}>
    <div className={thing} />
</div>

Also just semantically I like how it uses 'native' `className` attriburte instead of `css` attribute.

1
besthelloworld•

Honestly I just hate the className prop. It's just so awkward and long for no good reason. Imo it should just have been class. Preact and Solid both compile JSX that uses class as the prop name without issue.

1