Skip to content

Registration & Login

Register a new user with email and password. Optionally include a display name and custom fields.

import { useAuth } from '@aerostack/react'
function RegisterForm() {
const { signUp, loading, error } = useAuth()
const handleRegister = async () => {
const result = await signUp(email, password, {
name: 'Jane Doe',
customFields: { plan: 'free' },
})
if (result.requiresVerification) {
// Show "check your email" message
}
}
}
const { signIn, user, loading, error } = useAuth()
await signIn('user@example.com', 'password')
// user is now populated
const { signOut } = useAuth()
// Invalidates refresh token server-side + clears local state
await signOut()

Tokens expire after 15 minutes by default. Use refreshAccessToken to silently renew:

const { refreshAccessToken, tokens } = useAuth()
// Called automatically by most SDK methods when a 401 is detected.
// You can also call it manually:
const newTokens = await refreshAccessToken(tokens.refreshToken)

Pass a Turnstile token to protect register and login from bots:

await signIn(email, password, turnstileToken)
await signUp(email, password, { turnstileToken })

See the REST API reference for the full endpoint spec.