Skip to content

Installation

Installing Amee

Install Amee using you’re package manager

Terminal window
npm i amee

Configure Environment

Generate a secret key for your app

You can use node to generate a secret key using crypto lib.

Terminal window
node -e "console.log(require('crypto').randomBytes(32).toString('base64'));"

Alternatively, if you’re on a Unix-based system, you can use the openssl command.

Linux or MacOS
openssl rand -base64 32

Next, add it to your .env.local file

.env.local
AUTH_SECRET=<YOUR SECRET KEY>

Initialize Amee

In a new file in the root directory of your app, import Amee and initialize it.

auth.ts
import Amee from "amee"
const options = {
secret: process.env.AUTH_SECRET,
cookieName: "sessionId"
}
type SessionData = {
name: string,
email: string
}
export const { createSession, validateSession } = Amee<SessionData>(options)