Menu

Post image 1
Post image 2
1 / 2
0

Authentication with MonkeysLegion 2.0 + Next.js / React

DEV Community·Jorge Peraza·26 days ago
#ZQ4hvMp6
#frontend#token#api#backend#common#user
Reading 0:00
15s threshold

A complete guide to implementing JWT-based registration, login, session persistence, and token refresh using the MonkeysLegion v2 API with a Next.js (or React) frontend. Table of Contents API Endpoints Overview Backend Setup (MonkeysLegion) Frontend: API Client Frontend: Auth Context Provider Frontend: Register Page Frontend: Login Page Frontend: Protected Routes Token Refresh Flow Common Issues & Solutions API Endpoints Overview MonkeysLegion v2 exposes the following auth endpoints under the /api/v2/auth prefix: Method Endpoint Auth Description POST /auth/register No Create a new user + company POST /auth/login No Authenticate and get JWT tokens POST /auth/refresh No Exchange refresh token for new access token GET /auth/me Yes Get authenticated user profile POST /auth/logout Yes Invalidate tokens POST /auth/forgot-password No Request password reset Response Shapes Login Response — POST /auth/login { "data" : { "access_token" : "eyJ0eXAiOiJKV1Q..." , "refresh_token" : "eyJ0eXAiOiJKV1Q..." , "token_type"…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More