A modern, full-stack Progressive Web Application built with Next.js 14, featuring Web3 authentication with Privy, and offline capabilities powered by Serwist.
- π Web3 Authentication: Seamless wallet connection and user authentication using Privy
- π± Progressive Web App: Full PWA capabilities with offline support via Serwist
- π Push Notifications: Web push notifications for user engagement
- π Dark/Light Mode: Responsive design with theme support
- π± Mobile-First: Optimized for mobile devices with install prompts
- β‘ Modern Stack: Built with Next.js 14, TypeScript, and Tailwind CSS
- Frontend: Next.js 14, React 18, TypeScript
- Styling: Tailwind CSS
- Web3: Privy, Wagmi, Viem
- PWA: Serwist (Service Worker)
- State Management: TanStack Query
- Notifications: Web Push API
Before you begin, ensure you have the following installed:
- Node.js (v18 or higher)
- A Privy account and App ID from privy.io
git clone https://github.com/monad-developers/next-serwist-privy-smart-wallet.git
cd next-serwist-privy-smart-wallet
npm install
Create a .env.local
file in the root directory:
# Option 1: Copy from example (if .env.example exists)
cp .env.example .env.local
# Option 2: Create manually
touch .env.local
Add the following environment variables to your .env.local
file:
#Β Privy
NEXT_PUBLIC_PRIVY_APP_ID=your_privy_app_id_here
NEXT_PUBLIC_PRIVY_CLIENT_ID= # optional, you can leave this empty
# Web Push
WEB_PUSH_EMAIL=user@example.com
WEB_PUSH_PRIVATE_KEY=your_vapid_private_key
NEXT_PUBLIC_WEB_PUSH_PUBLIC_KEY=your_vapid_public_key
# Pimlico
NEXT_PUBLIC_PIMLICO_BUNDLER_URL=your_pimlico_bundler_url
Important: Replace all placeholder values with your actual credentials. See the steps below for obtaining these values.
Generate VAPID keys for web push notifications:
npx web-push generate-vapid-keys --json
Copy the generated keys to your .env.local
file.
- Visit privy.io and create an account
- Create a new app, choose Web as the Platform and create the app
- Right after creating the app, copy the App ID
- Add the App ID to your
.env.local
file
npm run dev
The application will be available at http://localhost:3000
.
For full PWA functionality (including install prompts):
npm run build && npm run start
- Desktop: Install button appears in supported browsers
- Mobile: Add to Home Screen prompts on iOS/Android
- Offline: Service worker enables offline functionality
The app includes web push notification capabilities for user engagement and updates.
Important
Enable notifications for the best experience!
To receive push notifications from this app, you need to enable notifications in your browser and/or system settings:
Chrome/Edge:
- Click the lock icon π in the address bar
- Set "Notifications" to "Allow"
- Or go to Settings β Privacy and security β Site Settings β Notifications
Firefox:
- Click the shield icon π‘οΈ in the address bar
- Turn off "Enhanced Tracking Protection" for this site (if needed)
- Allow notifications when prompted
- Or go to Settings β Privacy & Security β Permissions β Notifications
Safari:
- Go to Safari β Settings β Websites β Notifications
- Find your site and set it to "Allow"
macOS:
- System Preferences β Notifications & Focus
- Find your browser and ensure notifications are enabled
- Check "Allow notifications from websites" in browser settings
Windows:
- Settings β System β Notifications & actions
- Ensure your browser can send notifications
- Check browser notification settings
iOS:
- Settings β Notifications β [Your Browser]
- Enable "Allow Notifications"
- Also enable in browser settings
Android:
- Settings β Apps β [Your Browser] β Notifications
- Enable notifications
- Check browser notification permissions
Note
The SendNotification.tsx
component is sample code that requires backend implementation:
- Save subscription data when users subscribe (see TODO comments in code)
- Delete subscription data when users unsubscribe
- Implement
/notification
endpoint to send actual push notifications - Use
web-push
library or similar for server-side notification delivery
To customize your push notification content, edit app/notification/route.ts
and modify the title
, message
, icon
, and other properties in the sendNotification
call.
- Edit the
manifest.json
file - Change the
name
andshort_name
fields - Run
npm run build
to update the app
next-serwist-privy-smart-wallet/
βββ app/
β βββ components/ # React components
β β βββ InstallPWA.tsx # PWA install prompt
β β βββ ...
β βββ ~offline/ # Offline page
β βββ ...
βββ public/ # Static assets
βββ ...
Replace the icon files in the public/icons/
directory with your custom icons:
icon-512x512.png
- Main app icon (512Γ512px)android-chrome-192x192.png
- Android icon (192Γ192px)apple-touch-icon.png
- iOS home screen icon (180Γ180px)
Also update the favicon:
public/favicon.ico
- Browser faviconapp/favicon.ico
- Next.js app favicon
Splash screens are automatically generated from your app icon and theme colors defined in manifest.json
. To customize:
- Update the
theme_color
andbackground_color
inpublic/manifest.json
- Ensure your main icon (
icon-512x512.png
) represents your brand - Run
npm run build
to apply changes
Tip: Use tools like PWA Asset Generator to create all required icon sizes from a single source image.
- UseLoginPrivy: Privy authentication integration
- InstallPWA: PWA installation prompts
The app integrates with:
- Privy: For Web3 authentication
- Web Push API: For notifications
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
If you encounter any issues or have questions:
- Join Monad Dev Discord
- Review the Privy documentation
- Check the Next.js 14 documentation
- Check the Serwist documentation