In this tutorial, you will learn how to build a secure, production-ready REST API using Nuxt 3 (Nitro backend) with JWT authentication, RSA-encrypted passwords, and complete User Management CRUD, backed by MySQL and tested using Postman.
This tutorial shows how to build a production-ready REST API using Nuxt 3 (Nitro backend) with:
-
๐ RSA-encrypted passwords
-
๐ JWT authentication
-
๐ฅ User Management CRUD
-
๐ MySQL database
-
๐งช Full Postman testing (JSON included)
๐ง What You Will Build
A backend API that supports:
-
User registration
-
Secure login with RSA + bcrypt
-
JWT-protected routes
-
User profile
-
Full User CRUD (Create, Read, Update, Delete)
-
Logout
-
Postman testing
๐ Authentication Flow (Simple)
-
Client encrypts password using RSA Public Key
-
Server decrypts using RSA Private Key
-
Password verified with bcrypt
-
JWT token generated
-
JWT protects all private routes
๐ฆ Requirements
-
Node.js 18+
-
Nuxt 3
-
MySQL 8+
-
OpenSSL
-
Postman
1️⃣ Create Nuxt 3 Project
2️⃣ Install Backend Dependencies
3️⃣ Correct Project Structure
⚠️ If this structure is wrong, routes WILL NOT work
4️⃣ Environment Variables (.env)
5️⃣ MySQL Database Setup
6️⃣ Generate RSA Keys
⚠️ Never commit private.pem
7️⃣ MySQL Connection
8️⃣ JWT Helper
9️⃣ RSA Decryption Helper
๐ Register API
๐งช JSON – Register User
1️⃣1️⃣ Login API (RSA + JWT)
๐งช JSON – Login
1️⃣2️⃣ JWT Middleware
1️⃣3️⃣ Profile API
1️⃣4️⃣ User Management CRUD
๐น List Users – /api/users
๐งช JSON – Create User
๐น Single User – /api/users/:id
๐งช JSON – Update User
1️⃣5️⃣ Logout API
▶️ Run Application
Base URL:
๐ฏ Final Result
You now have:
✅ RSA encrypted login
✅ JWT authentication
✅ Secure middleware
✅ Full User CRUD
✅ Correct Nuxt 3 routing
✅ All JSON bodies included
✅ Production-ready API
Want the full source code?
Download the complete Nuxt 3 JWT Authentication with RSA example from my GitHub repo here.

