Skip to main content

User Registration

Implement user registration in your application.


Registration Methods

MethodFlow
Email/PasswordUser provides email + password
Social LoginOAuth via Google, GitHub, LinkedIn, Facebook
Custom DatabaseAuthenticate against existing database

Email/Password Registration

Implementation Examples

'use client';

import { useRegistration } from '@syauth/nextjs';
// ... component code ...

Required Fields

FieldRequiredDescription
emailValid email address
passwordMinimum 8 characters
first_nameUser's first name
last_nameUser's last name

Password Requirements

Passwords must meet these requirements:

  • Minimum 8 characters
  • At least one uppercase letter
  • At least one lowercase letter
  • At least one number
  • At least one special character

Via Universal Login

When using Universal Login, users can register directly:

const { loginWithRedirect } = useSyAuth();

// Redirect to Universal Login which has both login and register options
loginWithRedirect();

The Universal Login page includes a "Create account" link.


Registration API

For custom implementations:

POST https://api.syauth.com/e/v1/register/
Content-Type: application/json
X-API-Key: your-api-key

{
"email": "[email protected]",
"password": "SecurePass123!",
"first_name": "John",
"last_name": "Doe"
}

Response:

{
"success": true,
"message": "Registration successful. Please verify your email.",
"user": {
"id": "uuid",
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe",
"email_verified": false
}
}

Post-Registration Flow

After registration:

  1. Verification Email Sent - User receives email with verification code
  2. User Verifies Email - Clicks link or enters code
  3. Account Activated - User can now log in
Register → Email Sent → Verify Code → Account Active → Login

Error Handling

ErrorDescriptionSolution
email_already_existsEmail already registeredPrompt to login instead
invalid_emailEmail format invalidValidate email format
weak_passwordPassword doesn't meet requirementsShow requirements
invalid_api_keyMissing or invalid API keyCheck configuration
const { register, error } = useRegistration();

// Error is a string with the error message
if (error === 'email_already_exists') {
// Handle duplicate email
}

Configuration

Registration requires an API key:

# .env.local
NEXT_PUBLIC_SYAUTH_API_KEY=your-api-key

Get your API key from the Dashboard under your Application settings.


Next Steps