Custom Authentication

Learn how to secure your application with Custom Authentication.

The Custom Authentication strategy in our template provides a simple yet effective starting point for managing user authentication. This approach is built using React Server Actions and relies on a cookie-based system for user identification and session management.

Get Started Wisely

While the Custom Authentication strategy is a valuable learning tool, we encourage you to evaluate your project's requirements and security considerations. Choose the authentication solution that aligns with your application's needs, security standards, and scalability goals. Implementing a robust authentication solution is crucial to ensuring a secure and seamless user experience.

Configuration

Next.js

Copy the following variables to your .env.local file:

NEXT_PUBLIC_AUTH_STRATEGY=CUSTOM

Vite

Copy the following variables to your .env.local file:

VITE_AUTH_STRATEGY=CUSTOM

How it Works

  1. User Login: When a user attempts to log in, the application sends a request to the mocked server containing the user's credentials. The server validates the credentials and generates a session token that is stored in a cookie or localStorage depending on the framework you are using.
  2. User Logout: When a user logs out, the application sends a request to the mocked server to clear the session token and remove the user's authentication status.

Social Login and OAuth

It's important to note that our Custom Authentication method doesn't include social login capabilities out of the box. Implementing social login requires intricate OAuth integrations with various platforms. We recommend using third-party solutions like Next Auth for streamlined OAuth-based social login functionality.

Exploring Alternatives

For production-grade applications and projects requiring advanced authentication features, we highly recommend considering alternative authentication solutions that offer comprehensive security features, social login integrations, and third-party support. Some popular alternatives include:

  • Auth0: A powerful authentication and authorization platform that offers robust security features, social login, and seamless integration options.
  • Clerk: A comprehensive authentication service with support for social login, multi-factor authentication, and user management.
  • Cognito: A fully managed identity service that provides user authentication and authorization capabilities.
  • Supabase: An open-source platform that provides authentication, database, and API functionalities, all tightly integrated and ready to use.

These alternatives offer additional benefits like OAuth support, multi-factor authentication (MFA), and user management interfaces, allowing you to focus on building your application's unique features.