Skip to main content

Quick Start

This guide shows how to integrate Auth7 in a few steps.


Step 1: Initialize Auth7​

const auth7 = require("auth7-kit");

auth7.init({
mongoURI: "mongodb://localhost:27017/auth7",
jwtSecret: "supersecret",
});

Step 2: Add Auth Routes​

const authRouter = auth7.router();

app.use("/auth", authRouter);

Now authentication endpoints are available.


Step 3: Available Endpoints​

EndpointDescription
POST /auth/registerRegister user
POST /auth/loginLogin user
POST /auth/logoutLogout user
POST /auth/verify-emailVerify email
POST /auth/reset-passwordReset password

Step 4: Protect Routes​

const { protect } = auth7.middleware;

app.get("/profile", protect, (req, res) => {
res.json(req.user);
});

Your authentication system is now ready.