Skip to content

Anonymous

AnonymousPlugin creates a temporary user identity before full account registration.

Generate the plugin schema and apply it with your application migrations:

Terminal window
better-auth-rs generate --plugins anonymous -o src/auth_schema.rs

Use the schema, configuration, and store from installation.

use crate::auth_schema::AppAuthSchema;
use better_auth::plugins::AnonymousPlugin;
use better_auth::sqlx::SqlxStore;
use better_auth::{AuthConfig, AuthResult, BetterAuth};
async fn build_auth(
config: AuthConfig,
store: SqlxStore<AppAuthSchema>,
) -> AuthResult<BetterAuth<AppAuthSchema>> {
BetterAuth::<AppAuthSchema>::new(config)
.store(store)
.plugin(AnonymousPlugin::new())
.build()
.await
}

Start with POST /sign-in/anonymous. Configure linking through AnonymousConfig and the LinkAnonymousAccount callback to transfer application-owned data when the visitor adopts a permanent identity. POST /delete-anonymous-user supports removal of the anonymous account.

The user’s anonymous state is part of the identity lifecycle; decide what temporary users can access in application authorization.

See the official Anonymous guide.