A production-ready Next.js 15 application providing free online calculators for percentage, BMI, and mortgage calculations. Built with TypeScript, Tailwind CSS, and shadcn/ui.
-
Three Professional Calculators:
- Percentage Calculator with step-by-step explanations and visual charts
- BMI & Body Fat Calculator with Navy method estimation
- Mortgage Calculator with amortization schedules
-
Programmatic SEO:
- ~100 pre-generated pages for common percentage queries
- Dynamic routing for "what is X% of Y" queries
- Optimized for search engines
-
Performance & SEO:
- Next.js 15 App Router with Edge Runtime
- Automatic sitemap generation
- Structured data (Schema.org)
- Fast page loads (target LCP < 2.0s)
-
Geo-blocking:
- Edge middleware blocking 23 Arabic country codes
- Always allows search engine bots
- Returns 451 status with noindex headers
-
User Experience:
- Dark/Light mode toggle
- Fully responsive design
- Client-side calculations (privacy-first)
- Framer Motion animations
-
Analytics & Monetization:
- Vercel Analytics integration
- Google Analytics 4 support
- Google AdSense placeholder components
- Node.js 18.17.0 or higher
- npm, yarn, or pnpm
- A Vercel account (for deployment)
-
Clone the repository:
git clone <repository-url> cd Percent-Lab
-
Install dependencies:
npm install # or yarn install # or pnpm install
-
Set up environment variables:
cp .env.example .env.local
-
Edit
.env.localwith your values:# Google Analytics (optional) NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX # Google AdSense (optional) NEXT_PUBLIC_ADSENSE_CLIENT=ca-pub-XXXXXXXXXX # Site URL (required for sitemap) SITE_URL=https://percentlab.app
Run the development server:
npm run devOpen http://localhost:3000 in your browser.
npm run dev- Start development servernpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run type-check- Run TypeScript type checkingnpm run format- Format code with Prettier
Build the application for production:
npm run buildThis will:
- Build the Next.js application
- Generate static pages for pSEO routes
- Run the
postbuildscript to generate sitemap
-
Install Vercel CLI:
npm i -g vercel
-
Login to Vercel:
vercel login
-
Deploy:
vercel --prod
- Push your code to GitHub
- Import the project in Vercel dashboard
- Configure environment variables in Vercel:
NEXT_PUBLIC_GA_IDNEXT_PUBLIC_ADSENSE_CLIENTSITE_URL
- Deploy
Since you're on the claude/percentlab-nextjs-app-* branch:
# Commit your changes
git add .
git commit -m "feat: complete percentlab application"
# Push to remote
git push -u origin claude/percentlab-nextjs-app-011CUzxxJFBxkp4Q39tvTka4Then create a pull request to merge into main/master branch.
Create a .env.local file with the following variables:
| Variable | Description | Required |
|---|---|---|
NEXT_PUBLIC_GA_ID |
Google Analytics 4 Measurement ID | Optional |
NEXT_PUBLIC_ADSENSE_CLIENT |
Google AdSense Publisher ID | Optional |
SITE_URL |
Your production domain URL | Yes |
- Go to Google Analytics
- Create a new GA4 property
- Get your Measurement ID (format:
G-XXXXXXXXXX) - Add to
.env.local:NEXT_PUBLIC_GA_ID=G-XXXXXXXXXX
-
Sign up for Google AdSense
-
Get approved for your domain
-
Get your Publisher ID (format:
ca-pub-XXXXXXXXXX) -
Add to
.env.local:NEXT_PUBLIC_ADSENSE_CLIENT=ca-pub-XXXXXXXXXX
-
Add AdSense script to your site:
In production, add this script to
app/layout.tsxin the<head>section:<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXXXXXXXX" crossorigin="anonymous" ></script>
Replace
XXXXXXXXXXwith your actual AdSense Publisher ID. -
Configure Ad Units:
- Log into your AdSense account
- Create ad units for each placement (top, bottom)
- Update the
slotprops in<AdsSlot />components with your actual slot IDs
Percent-Lab/
βββ app/
β βββ (pages)
β β βββ page.tsx # Home page
β β βββ percentage/page.tsx # Percentage calculator
β β βββ bmi/page.tsx # BMI calculator
β β βββ mortgage/page.tsx # Mortgage calculator
β β βββ about/page.tsx # About page
β β βββ privacy/page.tsx # Privacy policy
β β βββ terms/page.tsx # Terms of service
β βββ pseo/[slug]/page.tsx # pSEO dynamic route
β βββ layout.tsx # Root layout
β βββ providers.tsx # App providers
β βββ globals.css # Global styles
βββ components/
β βββ ui/ # shadcn/ui components
β βββ ads-slot.tsx # AdSense component
β βββ calculator-shell.tsx # Calculator wrapper
β βββ result-card.tsx # Result display
β βββ header.tsx # Site header
β βββ footer.tsx # Site footer
β βββ theme-toggle.tsx # Dark mode toggle
βββ lib/
β βββ utils.ts # Utility functions
β βββ pseo-generator.ts # pSEO slug generator
β βββ seo.ts # SEO helpers
βββ middleware.ts # Edge middleware (geo-blocking)
βββ next.config.js # Next.js configuration
βββ next-sitemap.config.js # Sitemap configuration
βββ tailwind.config.ts # Tailwind configuration
βββ tsconfig.json # TypeScript configuration
Edit app/globals.css to customize the color scheme:
:root {
--primary: 221.2 83.2% 53.3%; /* Change primary color */
/* ... other colors */
}Edit lib/pseo-generator.ts:
// Add more percentage/number combinations
const popularPercentages = [5, 10, 15, 20, 25, /* add more */];
const popularNumbers = [50, 100, 200, /* add more */];Then rebuild to regenerate static pages.
Edit middleware.ts to change blocked countries:
const BLOCKED_COUNTRIES = new Set([
"MA", "DZ", // Add or remove country codes
]);The sitemap is automatically generated after each build. It will be available at:
/sitemap.xml- Main sitemap/sitemap-0.xml- Pages sitemap
Generated automatically at /robots.txt
Structured data (Schema.org) is included on:
- Home page (WebApplication, FAQPage)
- Calculator pages (SoftwareApplication)
- pSEO pages (FAQPage, Article)
npm run type-checknpm run lintnpm run build
npm run startThen test the production build at http://localhost:3000
The application is optimized for performance:
- Edge Runtime for middleware and suitable routes
- Static Generation for pSEO pages
- Client-side calculations to reduce server load
- No images on initial load for faster LCP
- Code splitting with Next.js automatic optimization
- Minimal JavaScript for core functionality
Target metrics:
- LCP (Largest Contentful Paint): < 2.0s
- FID (First Input Delay): < 100ms
- CLS (Cumulative Layout Shift): < 0.1
- CSP Headers configured in
next.config.js - Geo-blocking via Edge middleware
- No data storage - all calculations client-side
- XSS Protection headers
- Frame protection headers
- Chrome (last 2 versions)
- Firefox (last 2 versions)
- Safari (last 2 versions)
- Edge (last 2 versions)
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is proprietary. All rights reserved.
For questions or support, contact: hello@percentlab.app
- Built with Next.js 15
- UI components from shadcn/ui
- Icons from Lucide
- Charts from Recharts
- Animations from Framer Motion
Built with β€οΈ for the community