A modern, production-ready One-Time Password (OTP) verification system with React components and Express.js backend. Designed for seamless integration into any web application or framework.
Author: Ashish Chaurasiya | Organization: Zeroaxiis
- π§ Email-based OTP verification with secure 6-digit codes
- βοΈ Ready-to-use React components for instant integration
- π Express.js API & middleware for backend implementation
- π§ Multi-framework support (Next.js, Angular, Vue, PHP, Python, etc.)
- π‘οΈ Built-in security with rate limiting, validation, and expiry
- π¨ Customizable UI & styling to match your design
- π± Responsive design for all devices
- π Production-ready and battle-tested
OTP_Verification_System/
βββ client/ # React Components
β βββ SendOtp.jsx # Email input & OTP sending
β βββ VerifyOtp.jsx # OTP verification component
βββ server/ # Express.js Backend
β βββ index.js # Main server
β βββ middleware/ # Reusable middleware
βββ lib/ # Shared utilities
βββ examples/ # Integration examples
βββ INTEGRATION.md # Detailed framework guide
βββ SECURITY.md # Security guidelines
# 1. Clone repository
git clone <repository-url>
cd OTP_Verification_System
# 2. Setup server
cd server
npm install
# 3. Configure environment
cp .env.example .env
# Edit .env with your email credentials
# 4. Start server
npm start
# Server runs on http://localhost:3300import { SendOtp, VerifyOtp } from './client/src';
function App() {
const [step, setStep] = useState('send');
const [email, setEmail] = useState('');
return (
<>
{step === 'send' && (
<SendOtp
onSuccess={(data) => {
setEmail(data.email);
setStep('verify');
}}
apiUrl="http://localhost:3300"
/>
)}
{step === 'verify' && (
<VerifyOtp
email={email}
onSuccess={() => console.log('Verified!')}
apiUrl="http://localhost:3300"
/>
)}
</>
);
}// pages/auth.js
import { SendOtp, VerifyOtp } from '../components/otp';
export default function Auth() {
// Implementation here
}// otp.service.ts
@Injectable()
export class OtpService {
sendOtp(email: string) {
return this.http.post('/api/sentotp', { email });
}
}<template>
<SendOtp @success="handleSuccess" />
</template>import { createOtpRoutes } from './middleware/otp-middleware.js';
app.use('/api', createOtpRoutes({
emailConfig: {
service: 'gmail',
user: process.env.EMAIL,
pass: process.env.PASSWORD
}
}));π For complete integration guides: View INTEGRATION.md
POST /sentotp
Content-Type: application/json
{
"email": "user@example.com"
}Response:
{
"success": true,
"message": "OTP sent successfully",
"email": "user@example.com"
}POST /verifyotp
Content-Type: application/json
{
"email": "user@example.com",
"otp": "123456"
}Response:
{
"success": true,
"message": "OTP verified successfully",
"email": "user@example.com"
}- Enable 2FA on your Google account
- Generate App Password:
- Google Account β Security β 2-Step Verification β App passwords
- Select "Mail" β Generate password
- Configure environment:
EMAIL=your-email@gmail.com
PASSWORD=generated-app-password
NODE_ENV=production
PORT=3300<SendOtp
placeholder="Enter your email address"
buttonText="Send Verification Code"
className="custom-send-otp"
onSuccess={(data) => console.log(data)}
onError={(error) => console.error(error)}
/>
<VerifyOtp
email="user@example.com"
otpLength={6}
autoSubmit={true}
className="custom-verify-otp"
onSuccess={(data) => console.log(data)}
/>FROM node:18-alpine
WORKDIR /app
COPY server/ .
RUN npm install --production
EXPOSE 3300
CMD ["npm", "start"]NODE_ENV=production
EMAIL=production-email@domain.com
PASSWORD=production-app-password
PORT=3300
CORS_ORIGIN=https://yourdomain.com| Issue | Solution |
|---|---|
| Email not sending | Verify Gmail app password and 2FA |
| CORS errors | Configure CORS_ORIGIN in environment |
| Port conflicts | Change PORT in .env file |
| OTP expired | Default expiry is 5 minutes |
| Rate limiting | Wait 15 minutes or adjust limits |
NODE_ENV=development
DEBUG=trueThis system includes:
- β Rate limiting (5 attempts per 15 minutes)
- β OTP expiry (5 minutes default)
- β Email validation and sanitization
- β CORS protection
- β Input validation on all endpoints
Report security issues privately: ashishchaurasiya128@gmail.com
Email: ashishchaurasiya128@gmail.com
Create an issue on GitHub: Report Here
Author: Ashish Chaurasiya
Organization: Zeroaxiis
Contributors: DarkDeity666
MIT License - see LICENSE file for details.
If this project helped you, please β star this repository on GitHub!
Built with β€οΈ by Ashish Chaurasiya