Skip to main content
Email and password authentication is the most common authentication method. This guide shows you how to implement it with the SnackBase JavaScript SDK.

User Registration

Register a new user with email and password:
The password must meet your SnackInstance’s password requirements. The default minimum is 8 characters.

Registration Options

User Login

Log in an existing user with email and password:

Login Options

If you configured defaultAccount in the client, you can omit the account parameter from login requests.

Login with Default Account

Get Current User

After authentication, get the current user’s profile:

Password Reset Flow

1. Request Password Reset

Send a password reset email to the user:

2. Reset Password with Token

Use the token from the reset email to set a new password:

Email Verification

Check Email Verification Status

Send Verification Email

Verify Email with Token

Resend Verification Email

Complete Authentication Example

Here’s a complete example showing the full authentication flow:

React Integration

Using email/password authentication with React:

Error Handling

Handle common authentication errors:

Security Best Practices

1. Password Requirements

Ensure your SnackBase instance has secure password requirements:
  • Minimum 8 characters
  • Mix of letters, numbers, and symbols
  • No common passwords

2. HTTPS Only

Always use HTTPS in production:

3. Token Storage

Use appropriate storage for your use case:

4. Auto-Logout on Token Expiry

Configure the SDK to handle token expiry:

Next Steps