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
NeosiaNexus4w ago
Anonymous | Better Auth
Anonymous plugin for Better Auth.
Putra
PutraOP4w ago
Its using authClient const user = await authClient.signIn.anonymous() Does it work on server?
wagasa
wagasa4w ago
yes its a possible
Putra
PutraOP4w ago
How tho
wagasa
wagasa4w 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
lonelyplanet4w ago
all authClient endpoints are exposed by auth.api and this can be called on the server
lonelyplanet
lonelyplanet4w 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?