Installation

Complete the following steps as directed to use the project anjum authentication in your app. Kindly follow each and every step to setup the authentication.

Configure environment variables

 NEON_KEY=your_neon_key
 MAIL_USER=your_email
 MAIL_PASS=your_password

Go to the neon console to get your NEON_KEY i.e. "connection string"   from the project dashboard. If you want to use the email methods then make sure to also provide the MAIL_USER and MAIL_PASS too.

The MAIL_USER is simply the email address that you want to use to send emails to your users.
To get the MAIL_PASS follow the following steps.

  1. Go to your gmail account.
  2. Tap on profile and click "manage your google account".
  3. Go to security tab and scroll down to check if you have enabled two factor authentication. (if not then enable it)
  4. Go to search bar and search for "App passwords".
  5. click on it and enter your gmail password if prompted.
  6. Now enter your app name and click "create".
  7. You'll get the password string on screen.
Note

Remove the extra spaces in the password.

It should look something like this.

MAIL_PASS=bqderhgnwijknlnz
Warning

Do not change the naming of specified environment variables.

Install package

 npm install anjum 

This will install the necessary files from the npm registry. Depending on the internet connection it'll complete the installation.

Initialize the project

 npx anjum init 

Project anjum requires the configuration with server actions to run. This command will automatically figure out the project structure and create the necessary files. Just make sure you have your NEON_KEY in your env file. Also add the MAIL_USER and MAIL_PASS if you need email service.

Import methods

Now you are all set to import the methods in both client and server components. Here is an example of how you can import and use the methods in your component.

import { login, register, logout } from "@/actions/anjum";
 
const handleLogin = async ({
  email,
  password,
}: {
  email: string;
  password: string;
}) => {
  const res = await login({ email: email, password: password });
  return res;
};

On this page