8 Replies
Are you calling
authClient
or auth.api
?authClient
within layout.tsx
Since that's a server component, you should call
auth.api
, make sure to include headers in the fetchOptions
.Next.js integration | Better Auth
Integrate Better Auth with Next.js.
oh i mistook it
does this also work with routes?
Yeah. Any code ran on the server should use auth.api. If code is ran on the client, use authClient.
its server component not client
So, what would be "best practice" if I don't have the auth.api in NextJS because, for example, I do my authentication centrally with Express? I have a similar case, and unfortunately, it only works on localhost... 😦
https://discord.com/channels/1288403910284935179/1359765737140523060