A beautiful, modern Progressive Web App (PWA) for generating and scanning QR codes built with React, TypeScript, and Vite. Features offline support, responsive design, and a clean user interface.
- QR Code Generation: Create QR codes from text, URLs, or contact information (vCard format)
- QR Code Scanning: Real-time camera-based QR code scanning with automatic detection
- History Management: Track all generated and scanned QR codes with timestamps
- Progressive Web App: Installable on mobile and desktop devices
- Offline Support: Works without internet connection using service workers
- Responsive Design: Beautiful UI that works on all screen sizes
- Modern UI: Clean, pink-themed interface with smooth animations
- Copy to Clipboard: Easy copying of QR code content
- Download QR Codes: Save generated QR codes as PNG images
- Contact QR Codes: Generate vCard QR codes for contact sharing
View Live Demo (Replace with your actual Vercel URL)
The app includes beautiful screenshots for PWA installation:
- Wide format: 1280x720px
- Narrow format: 750x1334px
- Frontend: React 18.3.1 with TypeScript
- Build Tool: Vite 5.4.2
- Styling: Tailwind CSS 3.4.1
- QR Generation: qrcode 1.5.4
- QR Scanning: qr-scanner 1.4.2
- Icons: Lucide React 0.344.0
- PWA: Service Worker with offline caching
- Database: Supabase (configured but not actively used)
- Node.js (version 16 or higher)
- npm or yarn package manager
-
Clone the repository
git clone https://github.com/your-username/QR-Scanner.git cd QR-Scanner -
Install dependencies
npm install
-
Start development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
npm run buildThe built files will be in the dist directory.
npm run previewQR-Scanner/
βββ public/ # Static assets
β βββ manifest.json # PWA manifest
β βββ sw.js # Service worker
β βββ icon-*.png # App icons (72px to 512px)
β βββ screenshot-*.png # PWA screenshots
βββ src/
β βββ components/ # React components
β β βββ QRGenerator.tsx # QR code generation component
β β βββ QRScanner.tsx # QR code scanning component
β β βββ History.tsx # History management component
β βββ App.tsx # Main application component
β βββ main.tsx # Application entry point
β βββ index.css # Global styles
β βββ vite-env.d.ts # Vite type definitions
βββ package.json # Dependencies and scripts
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
βββ README.md # This file
The project uses Vite with optimized build settings:
- Code Splitting: Separate chunks for vendor libraries and QR-related packages
- Service Worker Support: Headers configured for service worker registration
- React Plugin: Fast refresh and HMR enabled
Custom styling configuration with:
- Pink color scheme (
#EC4899primary color) - Responsive design utilities
- Custom animations and transitions
Progressive Web App settings:
- App Name: "QR Master - Generator & Scanner"
- Theme Color: Pink (
#EC4899) - Display Mode: Standalone (app-like experience)
- Icons: Multiple sizes for different devices
- Shortcuts: Quick access to Generate and Scan features
- Purpose: Root component managing application state and navigation
- Key Features:
- Tab-based navigation (Generate, Scan, History)
- History state management with localStorage persistence
- PWA install prompt handling
- Responsive layout with gradient background
- Purpose: Generate QR codes from text or contact information
- Key Features:
- Dual-mode input (Text/URL and Contact vCard)
- Real-time QR code generation using
qrcodelibrary - Download functionality for generated QR codes
- Copy to clipboard functionality
- History integration
- Purpose: Scan QR codes using device camera
- Key Features:
- Camera access and video preview
- Real-time QR code detection using
qr-scannerlibrary - Automatic scanning with visual feedback
- URL detection and external link opening
- Copy scanned content to clipboard
- Error handling for camera permissions
- Purpose: Display and manage QR code history
- Key Features:
- Chronological display of generated and scanned codes
- Type-based categorization (Generated vs Scanned)
- Text truncation for long content
- Copy and open link functionality
- Clear all history option
The application uses React's built-in state management:
- Local State: Component-level state with
useState - Persistent Storage:
localStoragefor history persistence - Effect Hooks:
useEffectfor side effects and cleanup
Advanced offline functionality:
- Caching Strategy: Cache-first with network fallback
- Static Assets: Pre-cache essential files
- Dynamic Caching: Cache API responses and user-generated content
- Background Sync: Sync offline actions when back online
- Push Notifications: Support for push notifications
- Cache Cleanup: Automatic cleanup of old cached data
-
Push your code to GitHub
git add . git commit -m "Initial commit" git push origin main
-
Connect to Vercel
- Go to vercel.com
- Sign in with your GitHub account
- Click "New Project"
- Import your QR-Scanner repository
-
Configure Build Settings
- Framework Preset: Vite
- Build Command:
npm run build - Output Directory:
dist - Install Command:
npm install
-
Deploy
- Click "Deploy"
- Vercel will automatically build and deploy your app
-
Install Vercel CLI
npm i -g vercel
-
Login to Vercel
vercel login
-
Deploy
vercel
-
Follow the prompts
- Link to existing project or create new
- Configure settings as needed
-
Build the project
npm run build
-
Install Vercel CLI and deploy
npm i -g vercel vercel --prod
Create a vercel.json file for custom configuration:
{
"buildCommand": "npm run build",
"outputDirectory": "dist",
"framework": "vite",
"rewrites": [
{
"source": "/(.*)",
"destination": "/index.html"
}
],
"headers": [
{
"source": "/sw.js",
"headers": [
{
"key": "Service-Worker-Allowed",
"value": "/"
}
]
}
]
}If you plan to use Supabase or other services:
- Add environment variables in Vercel dashboard
- Create
.env.localfor local development - Update your code to use environment variables
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run linting
npm run lint- Mobile: Add to home screen from browser menu
- Desktop: Install prompt appears automatically
- Chrome: Install button in address bar
- Service Worker: Caches essential files
- Offline Mode: App works without internet
- Background Sync: Syncs when connection restored
- Generate QR: Quick access to generation
- Scan QR: Quick access to scanning
Update the primary color in tailwind.config.js:
module.exports = {
theme: {
extend: {
colors: {
primary: '#your-color-here'
}
}
}
}- Create new components in
src/components/ - Add routes in
App.tsx - Update navigation tabs
- Add to history if needed
-
Camera not working
- Ensure HTTPS is enabled (required for camera access)
- Check browser permissions
- Try different browsers
-
QR codes not generating
- Check console for errors
- Ensure input is not empty
- Verify qrcode library is installed
-
Service worker not registering
- Check browser console for errors
- Ensure HTTPS in production
- Verify sw.js is in public directory
-
Build errors
- Run
npm run buildto check for TypeScript errors - Ensure all dependencies are installed
- Check for missing imports
- Run
- Chrome: Full support
- Firefox: Full support
- Safari: Full support (iOS 11.3+)
- Edge: Full support
This project is open source and available under the MIT License.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed description
- Include browser version and error messages
- React - UI library
- Vite - Build tool
- Tailwind CSS - Styling
- QR Code - QR generation
- QR Scanner - QR scanning
- Lucide React - Icons
Made with β€οΈ using React & TypeScript