@rakered/nextjs-auth-api
v1.0.2
Published
api sdk for using @rakered/accounts with nextjs.
Downloads
10
Readme
@rakered/nextjs-auth-api
Next.js SDK for using user authentication persisted in MongoDB
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 providedBASE_URL String
The url that will be prefixed to magic urls and provided to the email template.
Optional if
options.email.siteUrl
is providedSITE_NAME String
The site name that will be provided to the email template.
Optional if
options.email.siteName
is providedLOGO_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