A sleek, modern, glassmorphic calculator application built with Next.js 16, Tailwind CSS v4, and Razorpay.
This application demonstrates a unique "Time-Based Premium Session" monetization strategy. The user gets a beautiful calculator interface, but mathematically resolving an operation requires an active session. A user can purchase a 10-minute premium session for exactly ₹1.00 via Razorpay.
- Gorgeous UI/UX: Dark mode, ambient glowing backgrounds, and modern Lucide icons.
- Component Architecture: Fully modular design separating UI (
CalculatorDisplay,Keypad,PremiumModal) from business logic. - Custom Hooks: Mathematical logic is isolated in
useCalculator, while session/payment logic lives inusePremiumSession. - Razorpay Integration: A secure Next.js Server App Route computes and creates the order ID. The client smoothly manages the checkout process without leaving the page.
- Session Continuity: 10-minute sessions survive page reloads utilizing browser
localStorage. - Live Timer: Shows exactly how much premium time is left.
- Framework: Next.js (App Router)
- Styling: Tailwind CSS via
@tailwindcss/postcss - Icons:
lucide-react - Payments:
razorpay(Server SDK) & Razorpay Checkout JS Library
Create a .env.local file at the root of the project to hold your Razorpay Test Keys:
NEXT_PUBLIC_RAZORPAY_KEY_ID="rzp_test_xxxxxx"
RAZORPAY_KEY_ID="rzp_test_xxxxxx"
RAZORPAY_KEY_SECRET="your_razorpay_secret"npm install
# or
yarn installnpm run devOpen http://localhost:3000 with your browser to see the result.
src/
├── app/
│ ├── api/create-order/route.ts # Secure backend order creation
│ ├── globals.css # Tailwind imports
│ ├── layout.tsx # Root layout
│ └── page.tsx # Main controller container
├── components/
│ ├── CalculatorDisplay.tsx # Timer and mathematical display
│ ├── Keypad.tsx # Buttons grid logic
│ └── PremiumModal.tsx # Purchase overlay
└── hooks/
├── useCalculator.ts # Math execution state
└── usePremiumSession.ts # Razorpay tracking & localstorage
The actual payment amount (100 paise / ₹1) is strictly enforced and verified over server-side Node execution inside /api/create-order, making it tamper-proof against frontend modifications.