Clerk login auth localhost error
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
I'm implementing 'login' button with Clerk.dev. I came across this Runtime Error in localhost:3000 indicating at auth() (line 6) can only be used in a server environment. Isn't my Button.tsx code already in a server environment?
12 Replies
Does your button being imported by a client component? Try adding
import 'server-only' to ensure thatPolar bearOP
Hmm I'm getting this error?
and yes button is imported by one of the client components.
I guess the error is that Button.tsx is assumed to be a client component since it's being exported to index.tsx, which is client component..?
this is the client component where line 3 (import Navbar from "./navbar") I try to import the button from.
Don’t import the button in a client component
So you have to pass the object as a prop, or make
Navigation a server component by removing “use clientâ€Polar bearOP
ohh i see
never knew it's bit of a hassle to do client -> server
thanks!