Next.js Discord

Discord Forum

usage of Link component

Answered
American Chinchilla posted this in #help-forum
Open in Discord
American ChinchillaOP
<Button
      onClick={() => push(href)}
      className={cn("flex gap-2 my-auto cursor-pointer", className)}
      {...props}
    >
      ...
    </Button>
hey i have this Button component from shadcn ui but i would like to redirect user on click however i heard i should use Link component to do that how can i do so in this case?
should i wrap whole button in Link component and move classes to Link instead?
Answered by Ant
You can achive this with asChild as seen here: https://ui.shadcn.com/docs/components/button#as-child
View full answer

2 Replies