1.0.2 • Published 3 years ago

@rakered/nextjs-auth-api v1.0.2

Weekly downloads
-
License
AGPL-3.0 OR COMME...
Repository
github
Last release
3 years ago

@rakered/nextjs-auth-api

Next.js SDK for using user authentication persisted in MongoDB

social image

Usage

Create a Dynamic API Route handler at /pages/api/auth/[...slug].js

import { handleAuth } from '@rakered/nextjs-auth-api';

export default handleAuth();

Getting Started

Environment Variables

The library needs the following required configuration keys. These can be configured in a .env.local file in the root of your application (See more info about loading environmental variables in Next.js):

  • MAIL_URL String

    The smtp url for the mail server to use.

    Optional when running in development mode

  • JWT_SECRET String

    The secret to sign the jwt tokens with.

  • EMAIL_FROM String

    The email address that's being used as sender.

    Optional if options.email.from is provided

  • BASE_URL String

    The url that will be prefixed to magic urls and provided to the email template.

    Optional if options.email.siteUrl is provided

  • SITE_NAME String

    The site name that will be provided to the email template.

    Optional if options.email.siteName is provided

  • LOGO_URL String

    The url for the logo that will be shown in the email.

    Optional if options.email.logoUrl is provided

API Route

Create a Dynamic API Route handler at /pages/api/auth/[...slug].js

import { handleAuth } from '@rakered/nextjs-auth-api';

export default handleAuth();

This will create the following urls:

/api/auth/create-account
/api/auth/enroll-account
/api/auth/login
/api/auth/logout
/api/auth/refresh-token
/api/auth/reset-password
/api/auth/verify-email
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago