Quick start guide for setting up the FarmCredit PWA.
- Node.js 20+
- npm or pnpm
- Git
# Using npm
npm install
# Or using pnpm
pnpm install# Using npm
npm install next-pwa @ducanh2912/next-pwa workbox-window
npm install -D @types/serviceworker sharp
# Or using pnpm
pnpm add next-pwa @ducanh2912/next-pwa workbox-window
pnpm add -D @types/serviceworker sharpThe project includes a placeholder SVG icon. To generate all required PNG icons:
npm run generate-iconsThis creates icons in the following sizes:
- 72x72, 96x96, 128x128, 144x144, 152x152, 192x192, 384x384, 512x512
To use your own icon:
- Create a PNG file (minimum 512x512px)
- Save it as
public/icon-source.png - Run
npm run generate-icons
For better app store presentation, add screenshots:
- Take a desktop screenshot (1280x720)
- Save as
public/screenshots/desktop-1.png - Take a mobile screenshot (750x1334)
- Save as
public/screenshots/mobile-1.png
# Build the production version
npm run build
# Start the production server
npm startOpen http://localhost:3000 in your browser.
- Open DevTools (F12)
- Go to Application tab
- Click "Service Workers" in the sidebar
- Verify "farmcredit-v1" is active
- In DevTools → Application tab
- Click "Manifest" in the sidebar
- Verify all fields are populated
- Check that all icons load without errors
- In DevTools → Application → Service Workers
- Check the "Offline" checkbox
- Refresh the page
- The app should still load from cache
- Navigate to a new route
- Should show the offline page if not cached
- Open the site in Chrome or Edge
- The install prompt should appear at the bottom
- Click "Install" to install the app
- The app should install and open in standalone mode
- Open DevTools (F12)
- Go to Lighthouse tab
- Select all categories
- Click "Generate report"
- Verify PWA score is 100
Expected scores:
- Performance: 90+
- Accessibility: 100
- Best Practices: 100
- SEO: 100
- PWA: 100
- Deploy to an HTTPS server (required for PWA)
- Open the site in Chrome on Android
- Tap the install prompt or Menu → "Install app"
- The app should install to your home screen
- Open the installed app
- Enable airplane mode and verify offline functionality
- Deploy to an HTTPS server
- Open the site in Safari on iOS
- Tap Share → "Add to Home Screen"
- The app should install to your home screen
- Open the installed app
- Enable airplane mode and verify offline functionality
To enable push notifications:
npx web-push generate-vapid-keysCreate .env.local:
NEXT_PUBLIC_VAPID_PUBLIC_KEY=your_public_key_here
VAPID_PRIVATE_KEY=your_private_key_hereimport { requestNotificationPermission, subscribeToPushNotifications } from '@/lib/notifications';
// Request permission
const permission = await requestNotificationPermission();
if (permission === 'granted') {
// Subscribe to push notifications
const subscription = await subscribeToPushNotifications();
console.log('Subscription:', subscription);
}- Ensure you're using HTTPS (or localhost)
- Check browser console for errors
- Clear cache and hard reload (Ctrl+Shift+R)
- Verify
public/sw.jsexists
- Run Lighthouse audit to check PWA criteria
- Clear site data and revisit
- Check if app is already installed
- Try in incognito mode
- Verify icons exist in
public/icons/ - Check manifest.json paths
- Clear browser cache
- Run
npm run generate-iconsagain
- Delete
.nextfolder and rebuild - Delete
node_modulesand reinstall - Check for TypeScript errors:
npm run build - Check for linting errors:
npm run lint
- Push to GitHub
- Import project in Vercel
- Add environment variables (if using push notifications)
- Deploy
Vercel automatically handles PWA requirements.
Ensure your hosting platform:
- Serves over HTTPS
- Serves
/sw.jswith correct headers - Serves
/manifest.jsonwith correct MIME type - Doesn't block service worker registration
- Customize the offline page design
- Add more routes to precache
- Implement background sync
- Add analytics for PWA metrics
- Customize install prompt timing
- Add more notification features
For issues or questions:
- Check the PWA Setup Guide
- Review browser console for errors
- Run Lighthouse audit for diagnostics
- Open an issue on GitHub