Next.js Discord

Discord Forum

Styled component doesn't work even I wrapped

Unanswered
Transvaal lion posted this in #help-forum
Open in Discord
Transvaal lionOP
Wrapper location ->
/src/lib$ ls
styled-components.tsx
and codes
'use client';

import { css, styled } from 'styled-components';

export { css, styled };
. I wrapped styled component like this as per documentation but still getting error when try to import on app/page.tsx . eerror -> Error: Attempted to call css() from the server but css is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component. . I am importing like this import { css } from '@/lib/styled-components';

4 Replies

Transvaal lionOP
so styled-component doesnt work even i follow their doc in nextJs 15 . i followed but doesnt work at all https://nextjs.org/docs/app/building-your-application/styling/css-in-js#styled-components
this is just time wasting BS
Rose-breasted Grosbeak
They have this example if you can't get it working from the docs, check this

https://github.com/vercel/next-app-router-playground/tree/main/app/styling/styled-components