SignIn Anonymous on Server

Is it possible? I dont see it on docs
Solution:
all authClient endpoints are exposed by auth.api and this can be called on the server
Jump to solution
8 Replies
NeosiaNexus
NeosiaNexus2mo ago
Anonymous | Better Auth
Anonymous plugin for Better Auth.
Putra
PutraOP2mo ago
Its using authClient const user = await authClient.signIn.anonymous() Does it work on server?
wagasa
wagasa2mo ago
yes its a possible
Putra
PutraOP2mo ago
How tho
wagasa
wagasa2mo ago
auth.ts
import { nextCookies } from 'better-auth/next-js'
import { anonymous } from 'better-auth/plugins'

export const auth = betterAuth({
plugins: [
anonymous(),
nextCookies(),
],
})
import { nextCookies } from 'better-auth/next-js'
import { anonymous } from 'better-auth/plugins'

export const auth = betterAuth({
plugins: [
anonymous(),
nextCookies(),
],
})
await auth.api.signInAnonymous() try it
Solution
lonelyplanet
lonelyplanet2mo ago
all authClient endpoints are exposed by auth.api and this can be called on the server
lonelyplanet
lonelyplanet2mo ago
"Any endpoint added to Better Auth, whether from plugins or the core, will be accessible through the api object."

Did you find this page helpful?