import { buttonVariants } from '@/components/ui/Button';
...
<Link
href='#'
className={cn(buttonVariants({ variant: 'text' }))}
>
Order <OutwardIcon />
</Link>
This error occurs only on the server side. If I add a 'use client' directive for the component/page then it works. That's weird; honestly, I don't know why this error happened, I haven't faced this error before.
Affected component/components
Button
How to reproduce
Install the Button component
Customize component with buttonVariants functions
Run the server-side component with it
Codesandbox/StackBlitz link
No response
Logs
⨯ src\app\page.tsx (73:46) @ HomePage
⨯ TypeError: (0 , _components_ui_Button__WEBPACK_IMPORTED_MODULE_9__.buttonVariants) is not a function
at HomePage (./src/app/page.tsx:190:168)
at stringify (<anonymous>)
digest: "708039026"
71 | <Link
72 | href='#'
> 73 | className={cn(buttonVariants({ variant: 'text' }))}
| ^
74 | >
75 | Order <OutwardIcon />
76 | </Link>
GET /_next/static/webpack/c08a93c280cc41ca.webpack.hot-update.json 404 in 2352ms
System Info
Next.js version:
`"next": "14.2.3"`
Radix UI slot component just in case:
`"@radix-ui/react-slot": "^1.0.2"`
Google Chrome version:
`125.0.6422.142`
Before submitting
[X] I've made research efforts and searched the documentation
Describe the bug
So I'm trying to use
buttonVariants
to customize the Next.js<Link>
component as a button but I got this error:This is how it looks: Button.tsx:
page.tsx (server side):
This error occurs only on the server side. If I add a
'use client'
directive for the component/page then it works. That's weird; honestly, I don't know why this error happened, I haven't faced this error before.Affected component/components
Button
How to reproduce
Codesandbox/StackBlitz link
No response
Logs
System Info
Before submitting