Registration
Navigate to the registration page
Click Sign up from the home page navigation, or visit
/register directly.Fill out the registration form
Provide the following information:
- Email (required): A valid email address that will be used to sign in
- Name (optional): Your display name
- Password (required): Must be at least 8 characters long
Submit the form
Click Sign up to create your account. The registration process:
- Normalizes your email (trimmed and lowercased)
- Hashes your password using bcrypt with 10 salt rounds
- Generates a unique 24-character user ID using nanoid
- Inserts your user record into the database
Emails are automatically converted to lowercase and trimmed of whitespace. If you register with
User@Example.com, you’ll sign in with user@example.com.Registration errors
You may encounter the following errors during registration:| Error | Cause | Solution |
|---|---|---|
Valid email is required | Invalid or missing email | Provide a valid email address |
Password must be at least 8 characters | Password too short | Use a password with 8+ characters |
Email already registered | Email already exists in database | Sign in instead, or use a different email |
Database not set up | Users table missing | Contact support or run npm run db:init if self-hosting |
Signing In
Enter your credentials
Provide:
- Email: The email you registered with
- Password: Your account password
The authentication system uses JWT sessions with a 30-day maximum age. Your session will remain active for 30 days unless you sign out.
Authentication errors
Common sign-in errors:Invalid email or password
Invalid email or password
This error appears when:
- The email doesn’t exist in the database
- The password doesn’t match the stored hash
- Either field is empty
Something went wrong
Something went wrong
A generic error indicating a network or server issue. Try again, and if the problem persists, check your network connection.
Callback URLs
When you’re redirected to the login page (e.g., when trying to access a protected page), acallbackUrl parameter is added to the URL. After successful authentication, you’ll be redirected back to that page.
Example: /login?callbackUrl=/dashboard will redirect you to /dashboard after signing in.
Session Management
shrtnr uses NextAuth.js JWT-based sessions:- Strategy: JSON Web Token (JWT)
- Max age: 30 days (2,592,000 seconds)
- Token contents: User ID and email
- Session storage: HTTP-only cookies
Session information
Your session contains:Signing Out
To sign out of your account:- Click your profile icon or name in the navigation bar
- Select Sign out
- Your session will be cleared and you’ll be redirected to the home page
Authentication Implementation Details
For developers interested in the technical implementation:NextAuth Configuration
The authentication configuration is defined inauth.ts:6:
Password Security
- Passwords are hashed using bcrypt with 10 salt rounds
- Original passwords are never stored in the database
- Password comparison uses constant-time comparison via
bcrypt.compare()
Registration API
The registration endpoint is at/api/auth/register and accepts:
The name field is optional. If not provided or empty, it will be stored as
null in the database.